Compiler Error C3351
Visual Studio .NET 2003
'object' : if you pass a NULL object instance to a delegate constructor you must also pass the address of a static member function
The compiler expected the address of a function declared static.
The following sample generates C3351:
// C3351.cpp
// compile with: /clr
#using <mscorlib.dll>
__delegate int D(int, int);
__gc class C {
public:
int mf(int, int) {
// declare the function as static
// static int mf(int, int) {
return 1;
}
};
int main() {
C *pC = new C;
System::Delegate *pD = new D(0, &C::mf); // C3351
}