c++可以通過對自定義類的運算符重載使得自定義類可以像int string等一樣方便地進行+ - × / 和輸入輸出等操作,類的運算符重載方式可以通過定義成員函數或者通過友元函數的方式重載,其中運算符<<和>>只能通過友元函數的方式重載,http://en.cpPReference.com/w/cpp/language/Operators 這里解釋道:Since they take the user-defined type as the right argument (b in a@b), they must be implemented as non-members. 另外可以看msdn: https://msdn.microsoft.com/en-us/library/1z2f6c2k.aspx