編譯器錯誤 C2663
'function' :數位多載沒有 'this' 指標的法律轉換
編譯程式無法轉換成 this
成員函式的任何多載版本。
此錯誤可能是在物件上const
叫用非const
成員函式所造成。 可能的解決方案:
const
從物件宣告中移除 。將 新增
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
}