This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Another template/static member question


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);
}

Attachment: PGP.sig
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]