Muokkaa

Jaa


Compiler Error C3367

'static_member_function' : cannot use static function to create an unbound delegate

When you call an unbound delegate, you must pass an instance of an object. Since a static member function is called through the class name, you can only instantiate an unbound delegate with an instance member function.

For more information about unbound delegates, see How to: Define and Use Delegates (C++/CLI).

Example

The following sample generates C3367.

// C3367.cpp
// compile with: /clr
ref struct R {
   void b() {}
   static void f() {}
};

delegate void Del(R^);

int main() {
   Del ^ a = gcnew Del(&R::b);   // OK
   Del ^ b = gcnew Del(&R::f);   // C3367
}