Another template/static member question
Harvey Chapman
hchapman-gcc-help@3gfp.com
Wed Feb 13 05:07:00 GMT 2008
I'm trying to compile the code below and keep getting this error. I'm
not exactly sure what to do to correct it. Is there something that I
could read that would help? What is a non_lazy_ptr?
Thank you,
Harvey
Undefined symbols:
"Singleton<SingleClass>::ptr", referenced from:
__ZN9SingletonI11SingleClassE3ptrE$non_lazy_ptr in ccvXYIGQ.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
#include <stdio.h>
template<class Type>
class Singleton
{
public:
static Type *ptr;
protected:
Singleton() { ptr = NULL; }
~Singleton() { }
};
class SingleClass : public Singleton<SingleClass>
{
friend class Singleton<SingleClass>;
};
template class Singleton<SingleClass>;
template <class Type> Type * Singleton<Type>::ptr;
// a test
//SingleClass * Singleton<SingleClass>::ptr;
int main()
{
return(0);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20080213/9126065a/attachment.sig>
More information about the Gcc-help
mailing list