Re: [問題] 解構子
重新看了一下你程式的邏輯 猜你大概不了解的是這邊的動作
: void ACount::openAcount(ACount user[])//開戶
: {
: char Name[20];
: int Password;
: cout<<"please input your name:"<<endl;
: cin>>Name;
: cout<<"please input your password:"<<endl;
: cin>>Password;
: user[ACount::count]=ACount(Name,Password);
這行的動作分解
產生一個暫時物件
呼叫建構子ACount(char[],int)
count 加 1
呼叫operator= (你沒給, Compiler送你一個member-wise copy
接著暫存物件刪除
count 減 1
: cout<<"success!"<<endl;
: cout<<count;
: system("pause");
: }
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.165.188.186
→
05/27 02:28, , 1F
05/27 02:28, 1F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章