关于成员函数指针和普通函数指针的转换
来源:互联网 发布:java直播平台源码 编辑:程序博客网 时间:2024/04/30 07:27
http://bbs.csdn.net/topics/10251675
查看九楼zdhe的回复。
a function call like following
p->func(100); // it will return nothing.
in C++ will be compiled to like following
push 64h //push parameter one by one. c++ always use ESP to pass parameter, because ECX is used for
//THIS pointer. there is no fastcall standard for C++
mov edx,p
mov eax,dword ptr [edx] //save vtable to eax
mov ecx,p // __this call standard ask compiler to save class poiner to ecx.
call dword ptr [eax+4] //it's func1 address, if must func, maybe [eax + 8],....
Have you got any idea?
so before get pointer , just do like following:
wait a common test func and see asmemble code ( for pi->play) , you will know shift
[eax + n] (n is waht you want .)
COM interface make sure this number will never change any more(else the caller program need rebuild ..hehe)
so
_asm{
mov edx,pi
mov eax,dword ptr [edx]
mov eax , [eax + n] //n is fix for you know.
}
then here, eax hold you p->Play ....
从汇编语言层面上证明了不可能直接进行转换。
不过boost::function 和 boost::bind 到底是怎么做到的需要追寻一下源码实现。
- 关于成员函数指针和普通函数指针的转换
- c++ 成员函数 普通函数指针转换
- 普通函数指针和指向成员函数指针(转载)
- 成员函数指针:(结构+与普通函数指针之间的转换)
- 普通函数指针与成员函数指针
- 类的普通成员函数的指针
- 类的普通成员函数的指针
- 类的普通成员函数的指针
- 普通函数指针与类成员函数指针的区别
- 成员函数指针作为参数传递给其他函数和普通函数指针的传递
- 成员函数指针和其他类型的强制转换,使用一般指针调用成员函数
- 普通的函数指针
- 向普通函数传递类成员函数指针的问题
- 向普通函数传递类成员函数指针的问题
- 类的成员函数指针作为参数传递给其他函数和普通函数指针的传递是不同的
- 类的成员函数指针作为参数传递给其他函数和普通函数指针的传递是不同的
- 类函数指针和普通函数指针
- 类函数指针和普通函数指针
- 腾讯校园招聘--一面(技术1对1)面经
- Tomcat域名或IP地址访问方式配置方法
- htonl(), ntohl(), htons(), ntohs() 函数
- UTF-8文件编码格式中有无签名问题汇总《转》
- Jquery Table 的基本操作
- 关于成员函数指针和普通函数指针的转换
- 2013.9.24 ArrayList和LinkedList的区别
- VS2010 Opened in another editor
- android手把手教你开发launcher(四)——显示widget
- boost epressive用法2
- 日期问题(华为2014年机试题——合肥——之三)
- i2c_client,i2c_adapter和I2C-core的简介
- 服务器、客户端之syslog()
- eclipse 开发的web项目