This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: c++ template class problem
- To: Toshinao ISHII <ici at qua dot crl dot melco dot co dot jp>
- Subject: Re: c++ template class problem
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 24 Sep 1998 01:32:44 +-300
- Cc: egcs at cygnus dot com
- References: <199809231033.TAA06844@rothko.qua.srl.melco.co.jp>
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