Re: [問題] 物件的定義 .. function為何不是物件?

看板C_and_CPP作者 (神崎・H・アリア)時間7年前 (2018/04/05 13:05), 7年前編輯推噓0(001)
留言1則, 1人參與, 7年前最新討論串2/2 (看更多)
首先必須釐清java的term和c++的東西並不完全相同 行為也不同 ex: generic, template, class.....等都是不一樣的 OO是C++才有的 如果不討論C 你找到的敘述我認為很合理 ※ 引述《alpho (阿否)》之銘言: : An object is a region of storage. : [ Note: A function is not an object, regardless of whether or not it occupies storage in the way that objects do. : —end note ] 在java之中宣告的class可以直接拿來使用 因為已經實體化 c++的class只是type 需要宣告並且變成變數instance 這個時候物件確實佔有一塊空間 https://www.quora.com/Is-this-statement-correct-An-object-is-an-instance-to-a-class-If-yes-then-why 太長縮 https://goo.gl/vqpbxg : 本來整個問題就是"物件的定義",然後有看到 應該是在14草案的3.9.2-3 沒記錯位置的話,說到:參考、函式和void型態不是物件。 : 參考很明顯,void和函式就比較微妙了。 : 為了釐清觀念,才在板上發問這樣 : 謝謝各位。 同樣的道理函式無法實體化 他只是一個symbol 一個進入點 容易讓人混淆的是c++有一個container叫做std::function 這是一個class 因為具有operator() 所以instance可以表現得像function 類似的還有lambda也是具有operator()的instance 其type只有compiler才知道 而void沒有任何東西 Cardinality就是0 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.223.80.137 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1522904749.A.831.html

04/05 14:34, 7年前 , 1F
symbol
04/05 14:34, 1F
謝謝指正 ※ 編輯: KanzakiHAria (61.223.80.137), 04/05/2018 14:44:24
文章代碼(AID): #1QnQwjWn (C_and_CPP)
文章代碼(AID): #1QnQwjWn (C_and_CPP)