c++/7049 Overloading "cout <<" in one namespace obscures similar functions in a different namespace
Philip Martin
philip@codematters.co.uk
Tue Jun 18 06:06:00 GMT 2002
This is not a bug, that's how name lookup works.
The compiler will lookup operator<< in the anonymous namespace where
the statement "cout << x" occurs, the std:: namespace where ostream is
defined, and the ns:: namespace where class X is defined. Since the
compiler will find an operator<< by doing this it won't look anywhere
else. In particular operator<< in the global namespace will not be
considered.
Put operator<< for X where it belongs, in the ns:: namespace that
defines class X.
--
Philip
More information about the Gcc-bugs
mailing list