TITLE: assignment and classes with references PROBLEM: floyd@whitelight.com (Floyd McWilliams) Suppose I have a class Foo that contains a reference to Bar: class Foo { public: ... Foo & operator=(const Foo & rhs); private: Bar &_bar; int _intVal; }; But I can't for the life of me figure out how to write op=: RESPONSE: clamage@Eng.Sun.COM (Steve Clamage), 19 Jan 96 You are probably thinking that you would like to redirect _bar to refer to what rhs._bar refers to. That isn't allowed in C++. As a consequence, a class containing reference members is likely to have inconsistent assignment semantics. Suppose you assign different Foo objects f1 = f2; Either f1._bar continues to refer to the same thing, which would violate the equality semantics of assignment (f1==f2 would be false after the assignment), or the thing f1._bar refers to would get the value of the thing f2._bar refers to. That preserves the equality semantics of assignment, but might not be appropriate for the assigment operator to do. You might want to consider not using a reference in class Foo, or disallowing assignment of Foo objects.