“delegate”:委托构造函数:参数必须是指向托管类或全局函数的成员函数的指针
委托构造函数的第二个参数采用成员函数的地址或任何类的静态成员函数的地址。 两者都被视为简单地址。
以下示例生成 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);
}