首页 > 代码库 > c++call back
c++call back
#include "stdafx.h"struct A;typedef void(A::*MemFuncPtr) (int* e);class A{ int a;}; class View : public A{public: virtual void test() { printf("test A\n"); }};class Window : public View{public: virtual void test() { printf("test A\n"); } void func(int * b) { (void)b; printf("************\n"); }};typedef void(*HandlerNoParam)();typedef void(*Handler1Param)(void* receiver);typedef void(*Handler2Param)(void* receiver, int* e);void test1(){ printf("no parameter test:\n");}void test2(void* receiver){ (void)receiver; printf("1 parameter test:\n");}void test3(void* receiver, int* e){ (void)receiver; (void)e; printf("2 parameter test:\n");}int _tmain(int argc, _TCHAR* argv[]){ Handler2Param p0 = (Handler2Param)test2; p0(NULL, 0); MemFuncPtr p = (MemFuncPtr)&Window::func; Window a; (a.*p)(NULL); getchar(); return 0;}
c++call back
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。