[問題] 建構子的問題
class CWin
{
private:
char c;
int width;
int hight;
public:
CWin() {}
CWin(char tmp='Q', int x=10, int y=20) { c=tmp, width=x, hight=y; }
void getValue() { cout << c << width << hight; }
}
int main()
{
CWin obj; /* ERROR: call of overloaded 'CWin()' is ambiguous */
CWin obj(); /* 編譯會過,但是這邊的 obj 不是一個物件?!?!? 到底是什麼東西 */
}
有點困惑 CWin obj 與 CWin obj()
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 68.68.96.46
推
01/18 14:28, , 1F
01/18 14:28, 1F
→
01/18 14:29, , 2F
01/18 14:29, 2F
→
01/18 14:30, , 3F
01/18 14:30, 3F
→
01/18 14:31, , 4F
01/18 14:31, 4F
推
01/18 16:30, , 5F
01/18 16:30, 5F
→
01/18 16:30, , 6F
01/18 16:30, 6F
→
01/18 16:31, , 7F
01/18 16:31, 7F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章