從C到C++快速入門(11. 運算符重載)

改進上面的程序,將 operator的 cout 輸出 s.name 和s.score 改進 : 加入輸入流運算符 cin istream& operator>>(istream &in, student &s) 因爲值傳遞的話,student s參數 傳到函數後並不會改變原本的值,所以我們需要用到& (引用)即 student &s參數 C++規定: 有的運算符, 比如加法( operator+
相關文章
相關標籤/搜索