
4 Dec
2007
4 Dec
'07
7:22 p.m.
That's because you cannot instantiate a class template with a string in C++.
Actually you can, but are limited to strings with external linkage. Another problem with this aspect of templates is that not all compilers support this syntax yet. -Sid Sacek #include <stdio.h> template< const char * name > class foo { const char * val; public: foo() : val( name ) { } const char * value( void ) { return val; } }; extern const char exname[] = "hello world"; int main( int, char ** ) { foo< exname > myfoo; printf( " %s \n", myfoo.value() ); }