class Fitness {
private:
int aweight;
int bweight;
public:
Fitness(void);
Fitness(int aw, int bw);
};
Fitness::Fitness(void)
{
if (ResetWeight) {
Fitness(ARG_AW, ARG_BW);
} else {
aweight=AWDEFAULT;
bweight=BWDEFAULT;
}
}
Fitness::Fitness(int aw, int bw)
{
aweight=aw;
bweight=bw;
}
不知道這樣子的constructor的用法有沒有什麼問題? 為什麼在ResetWeight=true時,
aweight和bweight會設定錯誤。我曾經加上一個destructor, 令人驚訝的是,
Fitness(int aw, int bw)這個constructor執行完, 竟會去run這個destructor???
這是什麼代誌啊???
--
╒══════╒══── ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ Graduate
╒╧══════ │ ﹏﹏ ─── ̄ ̄ Institute
│★ │ ﹏﹏ ── ̄ ̄ of
╭╯ ╭----- │ M.I.S.
│ ||Falcon/笨鳥 ───┘ NYUst
◤ ∟═╩═══ E-mail: gmi...@mis.yuntech.edu.tw
--
[m● Origin : 雲林科技大學藍天使 <bbs.yuntech.edu.tw> [FROM: 140.125.81.83]