A small detail of inheritance fancy on January 13, 2005 When we inherited a base class, not all everything would be inherited by subclavab. Constructor, destructor, assignment operator, hidden member functions. Constructor. If there is no declaration of the copy constructor, the compiler will automatically construct a replication constructor as the default replication. It will call all non-static members of the subclass and the copy constructor of the base class. Destructor. If there is no declaration function, all non-static data members and base classes have a destructor, then the compiler generates a default destructor that calls non-static data members and the destructor in the base class. Assignment operator. Also, if there is no declaration, the compiler will automatically generate one. It will call all non-statically data members and assignment operators in the base class. Hidden member functions. If the member functions existing in the base class are not rewritten in the derived class, and in the derived class, a member function that is the same but the number of parameters is different but the member function is hidden in the base class. .
Class a {public: void do (int i);}; class b {public: b ();}; class c: public a {public: void do (b &);
If we use this: c e; e.do (1); the compile period is generated, and the DO () in the base class A is hidden, and B cannot be converted to int. To avoid this happening, we should declare this: Class C: public a {public: void do (INT i); {a :: do (i);} void do (b &);}; this can prevent it The result of the appearance.