#include "stdafx.h"
using namespace System;
delegate void MyDelegate();
ref class MyClass{
public:
void f() { Console::WriteLine("MyClass::f"); }
void g() { Console::WriteLine("MyClass::g"); }
};
int main()
{
MyDelegate^ d;
MyClass^ r = gcnew MyClass();
d += gcnew MyDelegate(r, &MyClass::f);
d += gcnew MyDelegate(r, &MyClass::g);
d->Invoke();
d -= gcnew MyDelegate(r, &MyClass::g);
d();
}
|