As follows:Code:Class basic <br/>{< br/> Public: <br/> int data; <br/> protected: <br/> PRIVATE: <br/> }; </P> <p> class son: Public Basic <br/>{< br/> Public: <br/> son (): Data (0) {}< br/> protected: <br/> PRIVATE: <br/> };
When initializing a base class member, use the constructor member to initialize the list. However, an error is prompted when the following method is used:
Error c2614: "son": Invalid member initialization: "data" is not a base or member
In fact, this prompt is incorrect, but the error should also be located, because if Initialization is used in this case, if the base class has a default constructor, and it also shows that the base class members are initialized, so... is it covered? Yes, so it cannot be initialized like this. You can only assign values to the constructor of the derived class or call the constructor of the base class.