摘要: #includeusing namespace std ;class Base{ int basee ;public: Base(int base) { coutbasee = base ; } void show() { coutbase11 = base1 ; coutbase22 = base2 ; coutderived = derivied; }};int main(){ int derivied = 1 ; int derivedbase = 2 ; int base1 = 3 ; int base1base = 4 ; int base2 = 5 ; int base... 阅读全文
posted @ 2014-03-28 17:27 dot dot 小点点丶 阅读(333) 评论(0) 推荐(0) 编辑
摘要: 顺序:1,调用按照声明顺序的基类构造函数2,调用内嵌对象构造函数3,调用自身构造函数(总是先人后己嘛,先老人(基类)后客人(内嵌对象),自己家小孩儿就不要管大人之间的事儿(不调用派生类构造函数))这里C继承B和A,内嵌D,E继承C;调用构造函数情况:测试: 1 #include 2 using namespace std ; 3 class D 4 { 5 public: 6 D(){cout<<"initializing D..."<<endl;} 7 ~D(){cout<<"destroying D..."< 阅读全文
posted @ 2014-03-28 16:59 dot dot 小点点丶 阅读(823) 评论(0) 推荐(0) 编辑