看板 Programming 關於我們 聯絡資訊
想請問一個在寫class時的const的用法的問題, A:int& stack:: top() {return stk[top];} B:int& stack:: top() const{ return stk[top];} C:const int& stack::top() {return stk[top];} D:const int& stack:: top() const{ return stk[top];} 我想請問這四個的差異@@... 然後A,C跟B,D聽說不能共存, 不知道是不是因為A可以改傳回值,但是C不能。 B,D也是這種情況? 那B會發錯誤的話, 是因為傳回值不能改, 但是傳入的值可以變更嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.187.150
pinglunliao:return type 不屬於 parameter list 140.130.34.88 04/27 08:57
pinglunliao:Overloading 必須是參數列不同 140.130.34.88 04/27 08:57