c++ template class problem
Alexandre Oliva
oliva@dcc.unicamp.br
Thu Sep 24 02:37:00 GMT 1998
Toshinao ISHII <ici@qua.crl.melco.co.jp> writes:
> I tried compiling the following C++ source using template.
> g++ (egcs-2.92.07) give the following error.
> g++ -c poi01.C -g -frepo
> g++ -o poi01 poi01.o
> poi01.o: In function `main':
> /ici/work/test_template/poi01.C:27: undefined reference to \
> `ostream & operator<<<double>(ostream &, C<double> const &)'
On which platform? I can't reproduce this problem with the latest
snapshot of egcs on sparc-sun-solaris2.5.
BTW, you must declare the template function before you refer to it, as
suggested in the FAQ (the answer for friend templates was recently
updated; please take a look at it).
> In addition, the second parameter "C<double> const &" should be
> "const C<double> &".
Both are equivalent; the canonical representation prints cv-qualifiers
after the type to be qualified.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
More information about the Gcc
mailing list