看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: Win10, Linux, ...) Windows 10 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) VC++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 編譯時發生attemting to reference a delete function error 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) https://i.imgur.com/5tmxoOF.jpg 補充說明(Supplement): Card c = Card(1); // 正確 Card cs[1]; cs[0] = Card(1); // 錯誤 為何?? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.124.4.102 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1497708709.A.7E1.html
CoNsTaR: 就只是像字面上說的 Card 的 operator= 是 deleted funct 06/17 22:17
CoNsTaR: ion 而已吧… 06/17 22:17
CoNsTaR: Card c = Card(1) 只是單純的建構,沒有呼叫到 operator= 06/17 22:21
CoNsTaR: 所以沒事 06/17 22:21
CoNsTaR: 我記得板上有很多關於這方面的文章 06/17 22:21
pttuser: 沒有operate= assign constructor 06/17 23:29
chchwy: 你沒有給出Card的定義 是要我們猜囉? 06/18 10:04
Killercat: 現代大學作業會教deleted function了?真是進步了o_O 06/18 14:43
Killercat: 我以為大多數大學課程都停留在C++98 06/18 14:43
jerryh001: 不會(至少我們系沒教) 但是用內建的東西會遇到吧 06/18 19:01
Killercat: 內建碰到的機率頗低 而且原po很明顯是自己的class XD 06/18 20:26