This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
static template initialization pb
- To: egcs at cygnus dot com
- Subject: static template initialization pb
- From: <neal at ctd dot comsat dot com>
- Date: Sun, 30 Nov 1997 11:31:53 -0500
I believe the current standard should allow initialization in the
declaration, so this should work:
template<class T>
struct X {
static T c = 0;
};
//template<class T> T X<T>::c = 0;
X<int> W;
#include <iostream.h>
main () {
cout << W.c << endl;
}
-----------------------
Here's what happens with 971127 (linux):
g++ -o Test2 Test2.cc
/tmp/cca002091.o: In function `main':
/tmp/cca002091.o(.text+0x9): undefined reference to `X<int>::c'
collect2: ld returned 1 exit status