#pragma once
#include
测试代码:
#include "stdafx.h"
#include "Event.h"
#include <iostream>
class TestA
{
public:
void handler(void* sender, char* e)
{
std::cout<<"TestA.Handler\r\n";
}
};
class TestB
{
public:
event OnEvent;
void Raise(char* str)
{
OnEvent(NULL, str);
}
};
int _tmain(int argc, _TCHAR* argv[])
{
TestA a;
TestB b;
b.OnEvent += delegate(&a, &TestA::handler);
b.Raise();
system("PAUSE");
return 0;
}
结果:
![](http://hi.csdn.net/attachment/201202/5/0_1328431540hR2H.gif)