class A{
public:
A() {cout<<"Null constructor for A"<<endl;}
};
class B:public A{
public:
B() {cout<<"Null constructor for B"<<endl;}
B(int x) {cout<<"int constructor for B"<<endl;}
};
class C:public B{
public:
C() {cout<<"Null constructor for C"<<endl;}
C(int x):B(x) {cout<<"int constructor for C"<<endl;}
};
void main()
{
A a;
B b;
B bAlt(4);
C c;
C cAlt(3);
}
謝謝~~*^_^*
[m [1;31m※ 來源:‧靜宜大學計算機中心bbs站 bbs.pu.edu.tw‧[FROM: 61.66.103.55] [m
你編譯一下該 code,執行後就知道該答案了不是嗎?
--
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
現代人普遍的現象: 「小學而大遺」、「捨本而逐末」
「以偏而概全」、「因噎而廢食」
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--
[1;32m※ Origin: [33mSayYA 資訊站 [37m<bbs.sayya.org> [m
[1;31m◆ From: [36mkendlee.sayya.org [m
sorry 我是想問一下 B bAlt(4)
這行是什麼意思呢? 謝謝 *^_^*
-----------------------------------------
[m [1;32m※ 來源:‧靜宜大學計算機中心bbs站 bbs.pu.edu.tw‧[FROM: 61.66.103.55] [m
B這個類別有兩個constructor
其中一個有參數
B bAlt(4);
會執行有參數的那一個
參數代4
--
本當降、血雨...
--
[m※ Origin: 雲林科技大學藍天使 <bbs.yuntech.edu.tw> [From: 218.163.207.40]
懂了~~謝謝~~~~*^__________________^*~~
謝謝
--
-----------------------------------------
[m [1;33m※ 來源:‧靜宜大學計算機中心bbs站 bbs.pu.edu.tw‧[FROM: 61.66.103.55] [m