c++ delegate 的含义? 就是C++函数指针。 但是可以绑定上多个函数。实际上是functionPointer的封装类。
事件:事件是一个被进一步自动化了的委托. 在外边始终为类的私有变量。
(10)代理三步曲: a.生成自定义代理类:delegate int MyDelegate(); b.然后实例化代理类:MyDelegate d = new MyDelegate(MyClass.MyMethod); c.最后通过实例对象调用方法:int ret = d();
c#与c++如何过渡? 通过代理实现获得函数指针。 monther DLLs ->LoadDll() monther DLLs ->dllDrawing.DrawStart ---load DLLs---- get functionPointer ----- call it pDll = LoadDll(); pVersion = (DllVersionDelegate)GetDelegate("DllVersion", typeof(DllVersionDelegate)); pDraw = (DllDrawDelegate)GetDelegate("DllDraw", typeof(DllDrawDelegate)); pDrawStart = (DllDrawStartDelegate)GetDelegate("DllDrawStart", typeof(DllDrawStartDelegate)); pDrawStop = (DllDrawStopDelegate)GetDelegate("DllDrawStop", typeof(DllDrawStopDelegate));
|