This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: c++ template class problem


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]