class MyClass
{
int m_x;
public:
MyClass( int x ) { m_x = x; }
void Method( )
{
char arr[100];
wsprintfA( (LPSTR) &arr, "lol %d", m_x );
MessageBoxA( NULL, arr, "teehee", MB_OK );
}
};
DWORD WINAPI wrapperMethod( LPVOID lpParam )
{
MyClass *myClass = ( MyClass* ) lpParam;
if ( myClass != NULL )
myClass->Method( );
return 0;
}
int main( int argc, char **argv )
{
int x=0;
MyClass classy(12);
MyClass classy2(45);
// Here we instantiate two seperate instantiations of the class' Method function... but in a round about way.
// We really instantiate two thread of the wrapper method which then dereferences the class we pass in the LPVOID parameter. Fugly.
CreateThread( NULL, 0, &wrapperMethod, &classy, 0, NULL );
CreateThread( NULL, 0, &wrapperMethod, &classy2, 0, NULL );
// Infinite loop to let the threads execute.
while ( true )
{
x++;
}
return 0;
}