c++ template class problem
Todd Vierling
tv@pobox.com
Fri Sep 25 15:38:00 GMT 1998
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)
More information about the Gcc
mailing list