续"小题大作"再开一贴,两贴共151分,两天了,请各位指点一下,时间过地太快了。
各位好,小题是这样的:
有
对话框类:CMutexesDlg;
CWinThread 的派生类: CExampleThread;
CExampleThread 的派生类: CCounterThread 和 CDisplayThread;
1、想在CExampleThread 的头文件中填加如下变量:
CMutexesDlg * m_pOwner;// 指向类CMutexesDlg指针
及函数:
void SetOwner(CMutexesDlg* pOwner)
{ m_pOwner=pOwner; };// 取类CMutexesDlg的指针
2、想在CMutexesDlg 的头文件中加入如下成员变量:
CCounterThread* m_pCounterThread;
CDisplayThread* m_pDisplayThread;
问题是不知如何引用起头文件,请各位指点,谢谢。
现经人指点:
直接在头文件中声名CMutexesDlg类的前面加入:
//MutexesDlg.h
...
...
...
Class CCounterThread;//需要添加的
Class CDisplayThread;//需要添加的
...
//下面就是CMutexesDlg类的声名
Class CMutexesDlg:public CDialog
{
...
CCounterThread* m_pCounterThread;
CDisplayThread* m_pDisplayThread;
...
}
定义是可以了,可在引用时
m_pDisplayThread = (CDisplayThread*)AfxBeginThread(RUNTIME_CLASS(CDisplayThread),
THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
m_pDisplayThread->SetOwner(this);
出错:
error C2027: use of undefined type 'CDisplayThread'
mutexesdlg.h(16) : see declaration of 'CDisplayThread'
请各位指点啊