16,472
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <conio.h>
#include <windows.h>
class c
{
public:
c(int m, int n);
void set();
private:
int a;
int b;
};
c::c(int m, int n)
{
a = m;
b = n;
}
void c::set()
{
printf("%d %d", a, b);
}
c* pc = NULL;
DWORD WINAPI Thread(LPVOID lParam)
{
int a = 10, b = 20;
pc = new c(a, b);
pc->set();
return -1;
}
void main()
{
CreateThread(NULL, 0, Thread, 0, NULL, NULL);
pc->set();
getch();
}
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <windows.h>
HANDLE hEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
class c
{
public:
c(int m, int n);
void set();
private:
int a;
int b;
};
c::c(int m, int n)
{
a = m;
b = n;
}
void c::set()
{
printf("%d %d", a, b);
}
c* pc = NULL;
DWORD WINAPI Thread(LPVOID lParam)
{
int a = 10, b = 20;
pc = new c(a, b);
pc->set();
SetEvent(hEvent);
return -1;
}
void main()
{
CreateThread(NULL, 0, Thread, 0, NULL, NULL);
WaitForSingleObject(hEvent,INFINITE);
pc->set();
getch();
}