From: "A.Appleyard" To: DJGPP AT SUN DOT SOE DOT CLARKSON DOT EDU Date: Wed, 26 Jul 1995 11:16:45 BST Subject: class and subclass funny with operator= This test program:- class ground{public: double x,y; operator= (ground&g){x =g.x; y =g.y;}; operator+=(ground&g){x+=g.x; y+=g.y;};}; class air : public ground {public: double z;}; main(){ground G; air A; double n; n=A.x; n=A.y; n=A.z; A=A; A=G; G=A; G=G; A+=A; A+=G; G+=A; G+=G;} caused this compile error:- t$.cc: In function `int main()': t$.cc:8: bad argument 1 for function `class air & air::operator =(class air &)' (type was class ground) What's the matter? What's special about `='? I thought that the idea of subclasses was that e.g. an `air' value could be used in every way that a `ground' value could. What then is special about `=', so it faulted line 8 (`A=G;') but not line 12 (`A+=G;')? OK, in that case, `A.z' is not given a value; but perhaps I don't want to give it a value. If I declare a `class zxcvbnm{........};' or a `class zxcvbnm: public qwerty{.......};', when and when not is a `zxcvbnm::operator=(zxcvbnm&x){.......... /* binary copy */};' thereby automatically invisibly declared?