EDIT:私は完全に間違っているようです。このスレッドを閉じてください。ガー。レコードの クラスフレンドそのものを作る
、以下のコンパイルと動作します: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;
}
};
元の質問:私はにオブジェクトを渡す静的保護スレッドの方法を、持っています。どういうわけかクラスfriend
自身を作成してプライベートメンバーにアクセスできますか?
本当に必要ですか? –
ええ、私はメンバーの* looooot *を持っているので、私はそれらのすべてのアクセサを作成したくないです。 –
@Jonathan Lingle:ほとんどの現代のIDEは、アクセサの生成に手間取っています。メンテナンス性の面でそれは良い選択肢ではないでしょうか? – Asaph