Here is an example of a problem, which I tried to reduce to its
bare essentials:
// begin test1.cpp
class E {
public:
template<class T> static void f();
};
template<class T> void E::f() {}
class C {};
int main()
{
E::f<C>();
return 0;
}
// end test1.cpp
This compiles and links fine. Now I split the same code into three
different files:
// begin e.h
class E {
public:
template<class T> static void f();
};
// end e.h
// begin e.cpp
#include "e.h"
template<class T> void E::f() {}
// end e.cpp
// begin test2.cpp
#include "e.h"
class C {};
int main()
{
E::f<C>();
return 0;
}
// end test2.cpp
This compiles fine, but when I try to link (in Visual Studio 2003),
I get this error:
test error LNK2019: unresolved external symbol "public: static void
__cdecl E::f<class C>(void)" (??$f@VC@@@E@@S AXXZ) referenced in
function _main
What is wrong here?
--
Dmitry Epstein
Northwestern University, Evanston, IL. USA
mitia(at)northw estern(dot)edu
bare essentials:
// begin test1.cpp
class E {
public:
template<class T> static void f();
};
template<class T> void E::f() {}
class C {};
int main()
{
E::f<C>();
return 0;
}
// end test1.cpp
This compiles and links fine. Now I split the same code into three
different files:
// begin e.h
class E {
public:
template<class T> static void f();
};
// end e.h
// begin e.cpp
#include "e.h"
template<class T> void E::f() {}
// end e.cpp
// begin test2.cpp
#include "e.h"
class C {};
int main()
{
E::f<C>();
return 0;
}
// end test2.cpp
This compiles fine, but when I try to link (in Visual Studio 2003),
I get this error:
test error LNK2019: unresolved external symbol "public: static void
__cdecl E::f<class C>(void)" (??$f@VC@@@E@@S AXXZ) referenced in
function _main
What is wrong here?
--
Dmitry Epstein
Northwestern University, Evanston, IL. USA
mitia(at)northw estern(dot)edu
Comment