From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexandre Oliva To: Toshinao ISHII Cc: egcs@cygnus.com Subject: Re: c++ template class problem Date: Thu, 24 Sep 1998 02:37:00 -0000 Message-id: References: <199809231033.TAA06844@rothko.qua.srl.melco.co.jp> X-SW-Source: 1998-09/msg01312.html Toshinao ISHII 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<<(ostream &, C 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 const &" should be > "const C &". 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