I have a template function implemented in test.cpp.
test.h
Expand|Select|Wrap|Line Numbers
- class test
- {
- template<typename T>
- void function1( );
- }
- test.cpp
- {
- template<typename T>
- test::function1( )
- {
- statements
- }
- }
main.cpp
Expand|Select|Wrap|Line Numbers
- #include"test.h"
- main( )
- {
- test object1;
- object1.function1<float>( );
- }
test.obj : error LNK2001: unresolved external symbol "public: void __thiscall test::function1<float>(void)" (??$function1@M@test@@QAEXXZ)
If at all I call this function on the topmost of main.cpp instead of in the class and call it without any object I get no errors at all.
I am not able to identify the problem.Am I calling the template function in a wrong way?
Could anyone help me with this?
Thanks in advance.