Threads in Class

01/23/2013 15:51 ernilos#1
Hi guys! I'm wrritting a Class, i have that
Code:
class Player
{
private:
	/*......*/
	void UserThread(){
	std::cout << "Player connected and started the Thread!" << std::endl;
	};
	/*......*/
public:
	/*......*/
	void StartThread()
	{_beginthread(this->UserThread, 0,0);};
	/*......*/
};
Ok, i need start the void UserThread() as a thread, i tryed with _begin thread but give me a 'argument error' :C
01/23/2013 17:01 +Yazzn#2
Code:
class Player
{
private:
	static void thread(void *arg)
	{
		Player *_this = static_cast<Player *>(arg);

		//
		// We need the this ptr to call member functions etc.
		// For example:
		// _this->foo();
		//

		std::cout << "Player connected and started the Thread!" << std::endl;
	}

	//
	// void foo()
	// {
	//     ...
	// }
	//

public:
	void startThread()
	{
		_beginthread(thread, 0, this);
	}
};
01/23/2013 18:28 ernilos#3
Works Perfectly, thanks^^
Close pls:3