Bug with templates (c++)
Martin v. Loewis
martin@mira.isdn.cs.tu-berlin.de
Wed Mar 31 23:54:00 GMT 1999
> /tmp/cca038622.o(.text+0x24): undefined reference to `A<int>::A(int)'
Thanks for your report. This is a bug in your code, not in g++. If you
instantiate a template, it must be defined, not only declared (*). In
effect, this means that you have to define the templates in the header
file. Please have a look at the standard template library to see how
this is done.
The C++ standard allows an alternative approach: The 'export' keyword
provides a means to have external definitions of templates. This is
currently not supported by g++.
Regards,
Martin
(*) This is a requirement of the ISO C++ standard, not only of g++.
More information about the Gcc-bugs
mailing list