共用方式為


編譯器錯誤 C2803

「運算子運算子」至少必須擁有一個類別類型的型式參數

多載運算子缺少類別類型的參數。

您必須以傳址方式傳遞至少一個參數(不使用指標,但參考)或傳值,才能寫入 “a < b” (a 和 b 是類別 A 的類型)。

如果這兩個參數都是指標,它將會是指針位址的純比較,而且不會使用使用者定義的轉換。

下列範例會產生 C2803:

// C2803.cpp
// compile with: /c
class A{};
bool operator< (const A *left, const A *right);   // C2803
// try the following line instead
// bool operator< (const A& left, const A& right);