[comp.lang.c++] scoping problem with operator<< ?

leech@cassatt.cs.unc.edu (09/27/90)

    I've encountered a problem having to do with the scope at which an
output operator is declared, which appears to be a cfront bug.
Commentary would be appreciated.  This is using AT&T C++ 2.0 6/30/89,
or Sun C++ 2.0. The problem does not occur with g++ 1.36.1.

    Sample code is:

    #include <stream.h>

    class Anyptr {
    };

    #if !BUG
    extern ostream &operator<<(ostream &o, Anyptr &s);
    #endif

    main() {
    #if BUG
	extern ostream &operator<<(ostream &o, Anyptr &s);
    #endif

	Anyptr a;
	cout << a;
    }

    No errors occur if compiled without -DBUG; compiling with -DBUG
produces the error message:

"tst.c", line 16: error: bad operand types ostream_withassign Anyptr  for <<
--
    Jon Leech (leech@cs.unc.edu)    __@/
UNDERWHELMING OFFER OF THE MONTH:
    "Please feel free to skip the payment on this month's statement.
     Normal finance charges will apply." - NCNB VISA