Sdílet prostřednictvím


Chyba kompilátoru C3754

delegate constructor: členová funkce "function" nelze volat v instanci typu type 'type'

Poznámky

Volání funkce bylo provedeno ukazatelem na typ, který funkci neobsahuje.

Příklad

Následující příklad generuje C3754:

// C3754a.cpp
// compile with: /clr
using namespace System;

delegate void MyDel();

interface class MyInterface {};

ref struct MyClass : MyInterface {
   void f() {}
};

int main() {
   MyInterface^ p = gcnew MyClass;
   MyDel^ q = gcnew MyDel(p, &MyClass::f);   // C3754
   // try the following line instead
//   MyDel^ q = gcnew MyDel(safe_cast<MyClass^>(p), &MyClass::f);
}