C++?????м?????
???????????? ???????[ 2013/1/29 10:57:16 ] ????????
?????????????????л?????????????????C#??Objective-c????л????????????????????淶???????????????????????????л????????????????????????
????????о?C#??????????????????????????÷?????????Щ??C?????????????Objective-c??????????????????????????????д???????Objective-c??е????????п????????????????????????????????C#????У???C???????????????????????????????????????C#??????????????????????????????????????????д????????
???????????????????C++??????????????У?????????????????????????????й?C++????????????????????????????????????????п??????????????????????????????????????????????????ú??о???o??????????C++???????????????????????????????Ρ?
????C++?л???????????????
typedef void (*Fun)();
void function(Fun fun) {...}
???????????????????????????????????????????????“??????????????????”??
??????????????????????????????????????????к??????????????????????????????????????????
//event.h
#ifndef _EVENT_H_
#define _EVENT_H_
#include <string>
#include <iostream>
#include <vector>
using namespace std;
template <typename Handler>
class event //?????????????????п???????κ??????????????????У????????
{
public:
event()
{
}
event& operator+= (const Handler v)
{
add(v);
return *this;
}
event& operator-= (const Handler v)
{
remove(v);
return *this;
}
vector<Handler>& GetEvent()
{
return m_HandlerList;
}
protected:
virtual void add(Handler v)
{
m_HandlerList.push_back(v);
}
virtual void remove(const Handler v)
{
vector<Handler>::iterator it = m_HandlerList.begin();
for( ; it != m_HandlerList.end() ; it++)
{
if((*it) == v)
{
m_HandlerList.erase(it);
break;
}
}
}
private:
vector<Handler> m_HandlerList;
};
#endif
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11