Udostępnij za pomocą


Błąd kompilatora C3351

"object" : delegate konstruktor: drugi argument musi być adresem statycznej funkcji składowej lub funkcji globalnej

Uwagi

Kompilator oczekiwał adresu zadeklarowanej staticfunkcji .

Example

Poniższy przykład generuje kod 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);
}