Condividi tramite


Errore del compilatore C3754

costruttore delegato: la funzione membro 'function' non può essere chiamata in un'istanza di tipo 'type'

È stata effettuata una chiamata a una funzione tramite un puntatore a un tipo che non contiene la funzione.

Esempio

L'esempio seguente genera l'errore 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);
}