CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #1
    Join Date
    Aug 2005
    Posts
    10

    illegal call of non-static member function -help-

    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;
    }
    Last edited by BlueOrca; September 21st, 2005 at 01:14 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured