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, ); MemFuncPtr p = (MemFuncPtr)&Window::func;
Window a;
(a.*p)(NULL);
getchar();
return ;
}
随机推荐
- 【SQL】184. Department Highest Salary
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...
- hdu 4540 dp
题意: 假设: 1.每一个时刻我们只能打一只地鼠,并且打完以后该时刻出现的所有地鼠都会立刻消失: 2.老鼠出现的位置在一条直线上,如果上一个时刻我们在x1位置打地鼠,下一个时刻我们在x2位置打地鼠,那 ...
- 【洛谷】1852:[国家集训队]跳跳棋【LCA】【倍增?】
P1852 [国家集训队]跳跳棋 题目背景 原<奇怪的字符串>请前往 P2543 题目描述 跳跳棋是在一条数轴上进行的.棋子只能摆在整点上.每个点不能摆超过一个棋子. 我们用跳跳棋来做一个 ...
- poj 1509
求一个字符串在旋转置换群下最小字典表示. 用的是后缀数组(后缀自动机还是再听听jason_yu讲讲吧,关于right集合的部分还有问题) 最小表示法的思想很有好(判断两个对象在某一置换群划分下,是否等 ...
- BZOJ 4380 Myjnie 区间DP
4380: [POI2015]Myjnie Time Limit: 40 Sec Memory Limit: 256 MBSec Special JudgeSubmit: 162 Solved: ...
- Codeforces Round #293 (Div. 2) C. Anya and Smartphone 数学题
C. Anya and Smartphone time limit per test 1 second memory limit per test 256 megabytes input standa ...
- 记一次帮朋友解决apache站点403错误的过程
apache版本: [root@iZ25eby2utyZ web]# rpm -qa | grep httpd httpd-tools--.el6.centos..x86_64 httpd--.el6 ...
- Git_工作区和暂存区
Git和其他版本控制系统如SVN的一个不同之处就是有暂存区的概念. 先来看名词解释. 工作区(Working Directory):就是你在电脑里能看到的目录,比如我的learngit文件夹就是一个工 ...
- QQclient团队博客
Windows 8 视频採集 http://impd.tencent.com/?p=25 句柄泄漏检測工具的实现原理 http://impd.tencent.com/?p=29
- datagrid单元格格式化样式化
本文体验datagrid单元格的格式化和样式化. datagrid显示的DOM结构 <td field="code"> <div style="te ...