Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

請教一下以下c++之程式

0 views
Skip to first unread message

忍者軍團

unread,
Apr 9, 2003, 11:48:25 PM4/9/03
to

what is printed as a result of executing the following C++ code?

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

小州

unread,
Apr 10, 2003, 5:13:05 AM4/10/03
to
※ 引述《halu...@bbs.pu.edu.tw (忍者軍團 )》之銘言:

> what is printed as a result of executing the following C++ code?

你編譯一下該 code,執行後就知道該答案了不是嗎?

--
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

現代人普遍的現象: 「小學而大遺」、「捨本而逐末」
「以偏而概全」、「因噎而廢食」
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--
[1;32m※ Origin: [33mSayYA 資訊站 [37m<bbs.sayya.org> [m
[1;31m◆ From: [36mkendlee.sayya.org [m

忍者軍團

unread,
Apr 10, 2003, 6:41:32 AM4/10/03
to
【 在 kendue...@bbs.sayya.org (小州) 的大作中提到: 】
: ※ 引述《halu...@bbs.pu.edu.tw (忍者軍團 )》之銘言:

: > what is printed as a result of executing the following C++ code?
: 你編譯一下該 code,執行後就知道該答案了不是嗎?


sorry 我是想問一下 B bAlt(4)

這行是什麼意思呢? 謝謝 *^_^*

-----------------------------------------


[m [1;32m※ 來源:‧靜宜大學計算機中心bbs站 bbs.pu.edu.tw‧[FROM: 61.66.103.55] [m

宛如飛翔

unread,
Apr 10, 2003, 11:23:25 AM4/10/03
to
※ 引述《halu...@bbs.pu.edu.tw (忍者軍團 )》之銘言:
> 【 在 kendue...@bbs.sayya.org (小州) 的大作中提到: 】

> : 你編譯一下該 code,執行後就知道該答案了不是嗎?
> 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]

忍者軍團

unread,
Apr 10, 2003, 1:17:44 PM4/10/03
to
【 在 integr...@bbs.yuntech.edu.tw (宛如飛翔) 的大作中提到: 】
: ※ 引述《halu...@bbs.pu.edu.tw (忍者軍團 )》之銘言:
: > 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 [1;33m※ 來源:‧靜宜大學計算機中心bbs站 bbs.pu.edu.tw‧[FROM: 61.66.103.55] [m

0 new messages