- 12
- 0
- 约2.12万字
- 约 70页
- 2016-11-27 发布于河南
- 举报
Chapter11-StartingoutwithCearlyobjects
* * * * See pr11-20.cpp * * * See inheritance2.h, inheritance2.cpp, pr11-21App.cpp * See inheritance3.h, inheritance3.cpp, pr11-21.cpp * * * See pr11-08.cpp, NumberArray2.h, and NumberArray2.cpp * * * * See pr11-09.cpp, overload.h, and overload.cpp * * See Length.h, Length.cpp, pr11-10.cpp * * * * * See Length1.h, Length1.cpp, pr11-11.cpp for the first three * bulletsSee pr11-12.cpp for the string class’s overloaded [ ] operator; See intarray.h, intarray.cpp, pr11-13.cpp for these bullets * * * See Length2.h, Length2.cpp, and pr11-15.cpp * See Convert.h, Convert.cpp, and pr11-16.cpp * * * * See pr11-17.cpp * * * * See pr11-18.cpp and inheritance.h * * See inheritance1.h, inheritance1.cpp, pr11-19.cpp * * * * * Effect of Base Access 11-* private: x protected: y public: z private: x protected: y public: z private: x protected: y public: z Base class members x inaccessible private: y private: z x inaccessible protected: y protected: z x inaccessible protected: y public: z How base class members appear in derived class private base class protected base class public base class 11.12 Constructors,Destructors and Inheritance By inheriting every member of the base class, a derived class object contains a base class object The derived class constructor can specify which base class constructor should be used to initialize the base class object 11-* Order of Execution When an object of a derived class is created, the base class’s constructor is executed first, followed by the derived class’s constructor When an object of a derived class is destroyed, its destructor is called first, then that of the base class 11-* Order of Execution // Student – base class // UnderGrad – derived class // Both have constructors, destructors int main() { UnderGrad u1; ... return 0; }// end main 11-* Execute Student constructor, then execute UnderGrad constructor Execute UnderGrad destructor, then execute Student destructor P
原创力文档

文档评论(0)