ian: thanks so much for your assistance. On Sunday 28 December 2003 03:03, Ian Lance Taylor pronounced: > Allen Wayne Best <gcc@xxxxxxxxxxxxxxxxxx> writes: > > good idea; here is the complete file: > > Well, this example doesn't compile because you commented out the > > declaration of the relevant operator>>: > > // friend ostream& operator<<( ostream& o , const Sensor& s ) ; > > When I uncomment that line, the file compiles. > > When I try to link it, I get > > foo1.o(.text+0x6b): undefined reference to > `Measure::operator<<(std::ostream&, Measure::Sensor const&)' > > That's because of this line: > > ostream& operator<<( ostream& o , const Sensor& s) > > That defines operator<<, not Measure::operator<<. Your friend > declaration was inside namespace Measure. > > When I change the function definition to: > > ostream& Measure::operator<<( ostream& o , const Sensor& s) > > then the file compiles and links. > > > Alternatively, if I add these lines at the top: > > namespace Measure { class Sensor; } > extern ostream& operator<<( ostream& o , const Measure::Sensor& s ); > > and then change the friend declaration to > > friend ostream& ::operator<<( ostream& o , const Sensor& s ) ; > > then the file compiles and links. > > Ian -- regards, allen wayne best, esq "your friendly neighborhood rambler owner" "my rambler will go from 0 to 105" Current date: 22:33:9::361:2003 An egghead is one who stands firmly on both feet, in mid-air, on both sides of an issue. -- Homer Ferguson