精華區beta Programming 關於我們 聯絡資訊
TopWin.SetPos(x,y).SetSize(cx,cy).SetTitle("Hello World") ; cout << a << b << c << ... << blah ; : 推 MotherCon:所以他在底層的base class自訂.opr??? 59.113.171.167 07/29 05:38 : 推 MotherCon:複寫了很特殊的運算子說 59.113.171.167 07/29 05:41 : 推 march20:.opr? 不是吧, 是 << opr 傳回了 referenc 128.54.43.37 07/29 05:52 : 推 MotherCon:原文是用三個. 我是指這framework 59.113.171.167 07/29 06:45 : 推 MotherCon:可是那其實不算事.opr的預設行為 59.113.171.167 07/29 06:48 : 推 march20:嗯, 來實驗看看, 可能我 java 用太多了 128.54.43.37 07/29 06:53 實驗了一下, 不用 override .opr 就可以辦到這樣的事了 #include <iostream> using namespace std; class C{ public: C& X(){ cout << "X" << endl; return *this; } C& Y(){ cout << "Y" << endl; return *this; } C& Z(){ cout << "Z" << endl; return *this; } }; int main(){ C c; c.X().Y().Z(); return 0; } compiler: gcc 3.4.5, VC 7.1 執行結果: X Y Z -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 128.54.43.37 ※ 編輯: march20 來自: 128.54.43.37 (07/29 07:04)
MotherCon:喔喔 了 59.113.171.167 07/29 07:13