   Problem with operator = and copy constructors
class a{   public: a& operator = ( const a& rhs ) {    text = rhs.text;    return *this; } virtual ~a(void){}   protected: std::string text;};class b: public a{   public: b& operator = (const b& rhs) {    a::operator = (rhs);    text2 = rhs.text2;    return *this; } virtual ~b(void){}   protected: std::string text2;};class c: public b{   public: c& operator = (const c& rhs) {    b::operator = (rhs);    text3 = rhs.text3;    return *this; }    protected: std::string text3;};My problem is I am not sure what is the correct way to implement operator = for a derived class.For now I wouldnt mind if someone would verfiy that the above code is correct. Then I will state further problems. 
  Almost correct. Here''s how to do it right. ;  Calling an inherited function to assign is fine, but not all derived class = operators look like that. If an already written function does what you want, use it.   blah blah blah. ;  Ok my real problem is that when I call operator = of the third derived class (equivlanent to c in the example) the datamembers stay the same.I debugged the program and watch the variables in the classes and they dont change!What on earth could cause this? I thought that I was calling operator = the wrong way or something. Any ideas? ;  I'm not sure, but don't you have to implement your copy constructors?  Post the code that isn't working (i.e. the code that is using equals).   [edited by - rypyr on February 19, 2004 8:33:04 AM];  May be the cause of the problem is because you call the operator= form the base class ?in the class C: text3 = rhs.text3 is text3=rhs.text2 wich is text3 = rhs.textbut an object C has no menber text2 neither textso it does'nt workam I wrong ?   [edited by - Duguesclin on February 20, 2004 5:15:46 AM]