首页
社区
课程
招聘
[旧帖] [求助]关于offsetof计算的this指针 0.00雪花
发表于: 2011-6-23 18:08 3915

[旧帖] [求助]关于offsetof计算的this指针 0.00雪花

2011-6-23 18:08
3915
class COUT
{
        class CIN
        {
                int n;
                            void* GetThis()
                            {
                                 return (COUT*)((char*)this - offsetof(COUT, m_in));
                            }
        };
        CIN m_in;
};

不太理解

[课程]Linux pwn 探索篇!

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 113
活跃值: (100)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
2
使用嵌套类的this求得外面container的类的this指针。记得MFC里很多类这么用。
offsetof宏,MSDN有解释

offsetof  :
    Retrieves the offset of a member from the beginning of its parent structure, The offsetof macro returns the offset in bytes of memberName from the beginning of the structure specified by structName. You can specify types with the struct keyword.
2011-6-23 22:57
0
游客
登录 | 注册 方可回帖
返回
//