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: Todd Vierling <tv at pobox dot com>
- Date: Fri, 25 Sep 1998 14:50:40 -0400 (EDT)
- cc: egcs at cygnus dot com
On Wed, 23 Sep 1998, Toshinao ISHII wrote:
: g++ -c poi01.C -g -frepo
: g++ -o poi01 poi01.o
There are known but not admitted problems with -frepo on some platforms,
but: you do have a bug in your code unrelated to this.
: template <class T>
: ostream& operator << ( ostream &os, const C<T>& c )
: {
: os << c;
: return os;
: }
This function is recursive. It will call itself because you are doing `os
<< c' - which will call `operator << (ostream&, const C<T>&)' again, ad
infinitum. This needs to cast `c' to something which has a different
operator <<, or somehow extract the proper data, probably with:
os << c.v;
--
-- Todd Vierling (Personal tv@pobox.com; Bus. todd_vierling@xn.xerox.com)