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 ;
}
随机推荐
- 试水jdk8 stream
jdk8出来日子不短了,jdk11都出来了,不过用的最多的不过是1.5罢了. 今年终于鼓起勇气认真对待它,在18年记录下学习stream,画上一个圆. 先看个图 Java8中有两大最为重要的改变.第一 ...
- 300万大奖:欢迎参加美团联合主办的全球AI挑战赛
2018年8月29日,由美团.创新工场.搜狗.美图联合主办的“AI Challenger 2018全球AI挑战赛”正式启动.美团CTO罗道峰.创新工场CEO李开复.搜狗CEO王小川和美图CEO吴欣鸿共 ...
- python 与 mongodb的交互---查找
python与mongo数据库交互时,在查找的时候注意的一些小问题: 代码: from pymongo import * def find_func(): #创建连接对象 client = Mongo ...
- C# 集合类-使用
关联性集合类 关联性集合类即我们常说的键值对集合,允许我们通过Key来访问和维护集合. 我们来看一下 .net 为我们提供了哪些泛型的关联性集合类: Dictionary<TKey,TValu ...
- [Luogu5162]WD与积木(多项式求逆)
不要以为用上Stirling数就一定离正解更近,FFT都是从DP式本身出发的. 设f[i]为i个积木的所有方案的层数总和,g[i]为i个积木的方案数,则答案为$\frac{f[i]}{g[i]}$ 转 ...
- IE7 css兼容问题
1,float:right; 在IE错位问题 : 使用position:absolute:right:0px; 2,汉字在float状态下 折行 ,可能是因为父级宽度不够, 改用 display:in ...
- Codeforces Round #359 (Div. 1) A. Robbers' watch 暴力
A. Robbers' watch 题目连接: http://www.codeforces.com/contest/685/problem/A Description Robbers, who att ...
- An ac a day,keep wa away
zoj 初学者题: 1001 1037 1048 1049 1051 1067 1115 1151 1201 1205 1216 1240 1241 1242 1251 1292 1331 1334 ...
- hdu 4442 Physical Examination 贪心排序
Physical Examination Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDOJ 4414 Finding crosses 暴力!
Finding crosses Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...