Im still new to c++, and class's are some thing im still trying to work out but i carnt figure out what im doing rong here.
: error C2352: 'ThreadClass::StopGoFunc_Go' : illegal call of non-static member function
: error C2597: illegal reference to data member 'ThreadClass::StopGo' in a static member function
Code:class ThreadClass{ public: ThreadClass() { m_dwThreadID = 0; m_hThread = 0; } ~ThreadClass() { CloseHandle(m_hThread); } bool Creat_A_Thread() { m_hThread = CreateThread(0,0,StopGoThread,this,0,&m_dwThreadID); if(!m_hThread) { printf("Thread Failed"); return false; } return true; } void StopGoFunc_Go() { StopGo = true; } void StopGoFunc_Stop() { StopGo = false; } private: DWORD m_dwThreadID; HANDLE m_hThread; static DWORD WINAPI StopGoThread(LPVOID pvParam); bool StopGo; }; DWORD WINAPI ThreadClass::StopGoThread(LPVOID pvParam) { StopGoFunc_Go(); while(StopGo = true) { printf("Im Going"); Sleep(2500); } return 0; } int main() { ThreadClass MakeThread; MakeThread.Creat_A_Thread(); Sleep(10000); MakeThread.StopGoFunc_Stop(); return 0; }




Reply With Quote