Another template/static member question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux