Error del compilador C3351
'object': constructor delegado: el segundo argumento debe ser la dirección de una función miembro estática o una función global
El compilador esperaba la dirección de una función declarada static
.
El ejemplo siguiente genera la advertencia C3351:
// C3351a.cpp
// compile with: /clr
delegate int D(int, int);
ref class C {
public:
int mf(int, int) {
return 1;
}
static int mf2(int, int) {
return 1;
}
};
int main() {
System::Delegate ^pD = gcnew D(nullptr, &C::mf); // C3351
System::Delegate ^pD2 = gcnew D(&C::mf2);
}