Udostępnij za pomocą


Błąd kompilatora C3364

"delegate": konstruktor delegata: argument musi być wskaźnikiem do funkcji składowej klasy zarządzanej lub funkcji globalnej

Uwagi

Drugi parametr konstruktora delegata przyjmuje adres funkcji składowej lub adres statycznej funkcji składowej dowolnej klasy. Oba są traktowane jako proste adresy.

Example

Poniższy przykład generuje C3364:

// C3364_2.cpp
// compile with: /clr

delegate int D( int, int );

ref class C {
public:
   int mf( int, int ) {
      return 1;
   }
};

int main() {
   C^ pC = gcnew C;
   System::Delegate^ pD = gcnew D( pC,pC->mf( 1, 2 ) ); // C3364

   // try the following line instead
   // System::Delegate^ pD = gcnew D(pC, &C::mf);
}