共用方式為


編譯器錯誤 C2831

'operator operator' 不可以有預設參數

只有三個運算子可以有預設參數:

  • new

  • 工作分派 =

  • 左括弧 (

下列範例會產生 C2831:

// C2831.cpp
// compile with: /c
#define BINOP <=
class A {
public:
   int i;
   int operator BINOP(int x = 1) {   // C2831
   // try the following line instead
   // int operator BINOP(int x) {
      return i+x;
   }
};