編譯器錯誤 C3351
'object': 委派建構函式:第二個引數必須是靜態成員函式或全域函式的位址
編譯器必須有宣告為 static
之函式的位址。
下列範例會產生 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);
}