Hi all,
I have a template function implemented in test.cpp.
test.h
[code=cpp]
class test
{
template<typena me T>
void function1( );
}
test.cpp
{
template<typena me T>
test::function1 ( )
{
statements
}
}[/code]
Now I have my main program
main.cpp
[code=cpp]
#include"test.h "
main( )
{
test object1;
object1.functio n1<float>( );
}
[/code]
When I compile this rogram I get the linking error
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.
I have a template function implemented in test.cpp.
test.h
[code=cpp]
class test
{
template<typena me T>
void function1( );
}
test.cpp
{
template<typena me T>
test::function1 ( )
{
statements
}
}[/code]
Now I have my main program
main.cpp
[code=cpp]
#include"test.h "
main( )
{
test object1;
object1.functio n1<float>( );
}
[/code]
When I compile this rogram I get the linking error
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.
Comment