This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Undefined reference for static member of a template class
- From: Devrim Erdem <devrim at vires dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 12 Dec 2001 15:22:19 +0100
- Subject: Undefined reference for static member of a template class
Hello,
I have a template class like this :
template <class ObjType>
class Mingleton{
public:
static ObjType *OtherInstance( void ) {
if ( mInstance == 0 ) {
mInstance = new ObjType ;
}
return mInstance ;
}
static ObjType *mInstance ;
};
typedef Mingleton<ClassA> ClassB;
in .cpp file, I have :
ClassB::OtherInstance();
The compiler (gcc 2.95.2-149) reports a undefined refence error during
linkage. Any ideas ?
--
Devrim Erdem
-------------------------------------
VIRES Simulationstechnologie GmbH
Oberaustrasse 34
83026 Rosenheim
Germany
phone +49.8031.463640
fax +49.8031.463645
email devrim@vires.com
internet www.vires.com
-------------------------------------