Błąd kompilatora C2663Compiler Error C2663
"Function": przeciążenia numerów nie mają żadnych dozwolonych konwersji dla wskaźnika "This"'function' : number overloads have no legal conversions for 'this' pointer
Kompilator nie może wykonać konwersji this
do żadnej ze przeciążonych wersji funkcji składowej.The compiler could not convert this
to any of the overloaded versions of the member function.
Ten błąd może być spowodowany wywoływaniem const
funkcji nienależącej do elementu członkowskiego w const
obiekcie.This error can be caused by invoking a non-const
member function on a const
object. Możliwe rozwiązania:Possible resolutions:
Usuń
const
z deklaracji Object.Remove theconst
from the object declaration.Dodaj
const
do jednego z przeciążeń funkcji składowych.Addconst
to one of the member function overloads.
Poniższy przykład generuje C2663:The following sample generates 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
}