sdm@cs.brown.edu (Scott Meyers) (12/01/89)
Consider the following program:
#include <iostream.h>
enum Node_Type { stuff };
ostream& operator<<(ostream& s, const Node_Type& n);
class Node { public: int x; };
void foo(Node& n) { cout << n.x; }
When I try to compile it on a Sun Sparcstation with AT&T's 2.0 compiler,
this is what I get:
CC -c -g +p bug.C -o bug.o
CC +p bug.C:
"bug.C", line 9: error: int assigned to enum Node_Type
1 error
The error is caused by the "cout << n.x" statement. Since n.x is an int,
operator<< for int should be called, so I can't imagine why CC is trying
to convert it to a Node_Type. If I comment out my definition of
operator<< for Node_Type, everything is fine.
Is this a bug in CC, or have I done something wrong?
Scott
sdm@cs.brown.edu