共用方式為


編譯器錯誤 C2663

'function' :數位多載沒有 'this' 指標的法律轉換

編譯程式無法轉換成 this 成員函式的任何多載版本。

此錯誤可能是在物件上const叫用非const成員函式所造成。 可能的解決方案:

  1. const從物件宣告中移除 。

  2. 將 新增 const 至其中一個成員函式多載。

下列範例會產生 C2663:

// C2663.cpp
struct C {
   void f() volatile {}
   void f() {}
};

struct D {
   void f() volatile;
   void f() const {}
};

const C *pcc;
const D *pcd;

int main() {
   pcc->f();    // C2663
   pcd->f();    // OK
}