Undefined reference for static member of a template class

Devrim Erdem devrim@vires.com
Wed Dec 12 06:25:00 GMT 2001


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
-------------------------------------




More information about the Gcc-help mailing list