这么算回调吗
这样算回调吗?
类的回调是该怎么写?
如果以上不是的话,能不能给出一个例子 我想看看是怎么实现的。
网上没有找到合适的例子。
如果按照一个主程序,一个DLL来说,从类的角度说
DLL中定义接口类,在主程序中实现这个接口类,然后再怎么处理才能是一个回调呢?
求教了。
最好能有例子 光说看不明白啊
------解决方案--------------------
搜索 Command模式
------解决方案--------------------
#include "stdafx.h"
#include <iostream>
using namespace std;
class Delegate // interface in dll
{
public:
virtual void Print() const = 0;
};
class HelloWorld : public Delegate // implement in main
{
public:
virtual void Print() const
{
cout<<"Hello world!"<<endl;
}
};
class NiMei : public Delegate // implement in main
{
public:
virtual void Print() const
{
cout<<"aaaa"<<endl;
}
};
void DoSomething(Delegate* delegate)
{
//do anything you want
if (delegate != NULL)
{
delegate->Print();
}
}
int main(int argc, _TCHAR* argv[])
{
Delegate* p = new HelloWorld;
DoSomething(p);
delete p;
p = new NiMei;
DoSomething(p);
delete p;
system("pause");
return 0;
}
类的回调是该怎么写?
如果以上不是的话,能不能给出一个例子 我想看看是怎么实现的。
网上没有找到合适的例子。
如果按照一个主程序,一个DLL来说,从类的角度说
DLL中定义接口类,在主程序中实现这个接口类,然后再怎么处理才能是一个回调呢?
求教了。
最好能有例子 光说看不明白啊
------解决方案--------------------
搜索 Command模式
------解决方案--------------------