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

請問一下

0 views
Skip to first unread message

夜叉劍少異端神

unread,
Dec 12, 2002, 7:43:00 AM12/12/02
to

Constructor 裡面呼叫令一個Overloeading的Constructor怎ㄇ寫啊


C++的

我記得是

ex
class List{...}

List::List()
{
List::List(...)
}

Java好像是this.(....)

可是c++的我Compile不過ㄟ

--
淚....?為什麼我會流淚呢..?
有一種哀傷的感覺。

是XP! 我在電腦上灌了XP...
--
[1;31mO [1;32mr [1;33mi [1;34mg [1;35mi [1;36mn [1;31m: [1;36m<不良牛牧場> [1;33mzoo.ee.ntu.edu.tw [1;32m(140.112.18.36) [m
[1;32mWelcome to SimFarm BBS [1;36m-- [m [1;31mFrom : [ [mh220.n219-68-123.adsl.giga.net.tw [1;31m] [m

緋紅色

unread,
Dec 12, 2002, 12:49:12 PM12/12/02
to
※ 引述《cplusplus (緋紅色)》之銘言:
: this.::xxxx(....)
更正....
假設是A
this.A::A(....);

--
[m [1;33;46m〒作者:cplusplus 來自:214105.D5-214.ncu.edu.tw [m
[1;36m◎二進位的世界 [37m【140.115.50.50‧binary.csie.ncu.edu.tw

緋紅色

unread,
Dec 12, 2002, 12:48:18 PM12/12/02
to
this.::xxxx(....)

緋紅色

unread,
Dec 13, 2002, 12:40:36 AM12/13/02
to
※ 引述《Wa...@kkcity.com.tw (唉~~)》之銘言:
: ※ 引述《cplusp...@binary.csie.ncu.edu.tw (緋紅色)》之銘言:
: > 更正....
: > 假設是A
: > this.A::A(....);

啊靠 打錯啦>"<
this->A::A(....); 才對
sorry
上面那樣是有特殊用途才那樣用

class A
{
public:
A(.)
{..};
A(..)
{
if(...)
this->A::A(.);
else
......
}
};

--
All You See or Seen is Just a Dream within a Dream~~~

唉~~

unread,
Dec 13, 2002, 2:47:07 AM12/13/02
to
※ 引述《cplusp...@binary.csie.ncu.edu.tw (緋紅色)》之銘言:

> class A
> {
> public:
> A(.)
> {..};
> A(..)
> {
> if(...)
> this->A::A(.);
> else
> .......
> }
> };

1. 這種方法不是所有 compiler 都可以通過 (gcc 就不行)

2. 這樣做的結果跟預期的效果 ( Java 中的 this(...) ) 並不完全相同
只要該 class 有 member object 或是 base class 就會有問題
( member || base 會被建構兩次, 但只解構一次)

--
[1;32m┌───── [33m◆ [37mKKCITY [33m◆ [32m─────┐ [34m┐┌┐┐┌┐┌─┐┌┬┐┌┬┐┐ ┌ [m
[1;32m│ [31m bbs.kkcity.com.tw [32m│ [37m├┘┐├┘┐│ │ │ └┬┘ [m
[1;32m└── [34m《 [0;37mFrom:140.123.234.141 [1;34m》 [32m──┘ [36m┘ ┘┘ ┘└─┘└┴┘ ┴ ┴ [m

夜叉劍少異端神

unread,
Dec 13, 2002, 8:09:45 PM12/13/02
to
@.@
Compiler 不給過ㄟ

E


※ 引述《cplusp...@binary.csie.ncu.edu.tw (緋紅色)》之銘言:
: ※ 引述《Wa...@kkcity.com.tw (唉~~)》之銘言:
: 啊靠 打錯啦>"<


: this->A::A(....); 才對
: sorry
: 上面那樣是有特殊用途才那樣用

: class A


: {
: public:
: A(.)
: {..};
: A(..)
: {
: if(...)
: this->A::A(.);
: else
: .......

: }
: };

緋紅色

unread,
Dec 14, 2002, 6:45:58 AM12/14/02
to
※ 引述《Wa...@kkcity.com.tw (唉~~)》之銘言:
: ※ 引述《cplusp...@binary.csie.ncu.edu.tw (緋紅色)》之銘言:
: > class A
: > {
: > public:
: > A(.)
: > {..};
: > A(..)
: > {
: > if(...)
: > this->A::A(.);
: > else
: > .......
: > }
: > };
: 1. 這種方法不是所有 compiler 都可以通過 (gcc 就不行)

: 2. 這樣做的結果跟預期的效果 ( Java 中的 this(...) ) 並不完全相同
: 只要該 class 有 member object 或是 base class 就會有問題
: ( member || base 會被建構兩次, 但只解構一次)
喔 感謝你
第一點有考慮到....
第二點倒是沒考慮過,謝謝
不過到現在我還真正沒用到這方式 我也是以前看別人回的...@@
sorry 謝謝指正
0 new messages