共用方式為


編譯器錯誤 C3364

'delegate': 委派建構函式: 自變數必須是 Managed 類別或全域函式成員函式的指標

委派建構函式的第二個參數會採用成員函式的位址,或是任何類別之靜態成員函式的位址。 這兩者都會被視為簡單位址。

下列範例會產生 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);
}