作者smartjay (高毛毛)
看板C_and_CPP
標題[問題] class 的主體已經被宣告了
時間Fri Aug 5 17:17:25 2016
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC2015
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
none
問題(Question):
練習定義 員工此class 可以利用Set Get 設定及取得資訊
餵入的資料(Input):
Employee A("K","1991,11,11",10,20);
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
錯誤 C2084 函式 'void Employee::SetName(std::string)' 的主體已經被宣告了
.....
程式碼(Code):(請善用置底文網頁, 記得排版)
main :
http://ideone.com/yaEGAI
employee.h :
http://ideone.com/v1WdvU
employee.cpp :
http://ideone.com/GQRxrU
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.249.142.114
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1470388647.A.96A.html
※ 編輯: smartjay (60.249.142.114), 08/05/2016 17:20:33
→ Jockey66666: C2084 msdn 就有答案了 08/05 17:24
→ smartjay: THX 看懂在.h宣告時多{}造成無法重複 08/05 18:32
→ jerryh001: 可以直接點C2084那個字 會出現說明跟範例 08/05 19:40
推 ekids1234: 小心 .h 檔案,如果你寫了 void foo(){}; 07/09 18:39
→ ekids1234: 代表你在 .h 就令他為空函式了 07/09 18:40
→ ekids1234: 就會無法 implement 07/09 18:40