C++程序设计教程修订版 第17章 多重继承.pptVIP

  • 6
  • 0
  • 约1.55千字
  • 约 15页
  • 2018-01-05 发布于河南
  • 举报

C++程序设计教程修订版 第17章 多重继承.ppt

C程序设计教程修订版第17章多重继承

C++程序设计教程;多重继承;举例;class C : public A, private B { public: void SetC(int x, int y, int z) { SetA(x); SetB(y); c=z; } void ShowC() {coutcendl;} private: int c; };;多继承时的构造函数与析构函数;class B1 { public: B1(int i) {coutConstructing B1 iendl;} }; class B2 { public: B2(int j) {coutConstructing B2 jendl;} }; class B3 { public: B3() {coutConstructing B3 endl;} };;class C : public B2,public B1,public B3 //派生类 { public: C(int a, int b, int c, int d) :B1(a), memB2(d), memB1(c), B2(b){} private: B1 memB1; B2 memB2; B3 memB3; }; void main() { C obj(1,2,3,4); };继承的二义性;沙发;派生

文档评论(0)

1亿VIP精品文档

相关文档