编辑:看起来我完全被误导了.请关闭此帖子.嘎.
为了记录,以下编译和工作:
class ForeverAlone
{
private:
int m_friends;
HANDLE m_handle;
public:
ForeverAlone()
{
m_handle = CreateThread(NULL, 0, &ForeverAlone::SadThread, reinterpret_cast<void*>(this), 0, NULL);
}
~ForeverAlone()
{
if (m_handle != NULL)
CloseHandle(m_handle);
}
protected:
static unsigned long WINAPI SadThread(void* param)
{
ForeverAlone* thisObject = reinterpret_cast<ForeverAlone*>(param);
// is there any way for me to access:
thisObject->m_friends;
}
};
Run Code Online (Sandbox Code Playgroud)
原始问题:我有一个静态保护线程方法,我将一个对象传递给它.我可以以某种方式使类friend本身,所以我可以访问其私人成员?
| 归档时间: |
|
| 查看次数: |
4546 次 |
| 最近记录: |