From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arun Saini To: gcc@gcc.gnu.org Subject: Undefined reference to static member in templated class Date: Wed, 18 Jul 2001 09:43:00 -0000 Message-id: <20010718164254.68869.qmail@web10506.mail.yahoo.com> X-SW-Source: 2001-07/msg01279.html hi all, I am using gcc-2.95.3 on AIX 4.3.3 / RS/6000. I am enclosing here a small piece of code that compiled and executed correctly on gcc-3.0 on a Linux system. It however fails on the AIX system. #include enum eTables { tbl1, tbl2 }; template class test { private: static test * foo; protected: public: test(); virtual ~test(); static test *Instance(); }; //class test template test *test::foo = NULL; template test::test() { } template test::~test() { } template test *test::Instance() { if (foo == NULL) { foo = new test; } return(foo); } int main() { test *pobj; pobj = test::Instance(); } # g++ testFinal.cpp /tmp/cc8zh32c.o(.pr+0x13e):testFinal.cpp: undefined reference to `test::foo' /tmp/cc8zh32c.o(.pr+0x14e):testFinal.cpp: undefined reference to `test::foo' /tmp/cc8zh32c.o(.pr+0x21a):testFinal.cpp: undefined reference to `test::foo' /tmp/cc8zh32c.o(.tc+0x0):testFinal.cpp: undefined reference to `test::foo' collect2: ld returned 1 exit status Any ideas why this might be happening???? Arun Saini __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/