1.client.h
class Client{
public:
Client(){}
~Client(){}
static void* thread_func(void* pParm);
};
2.client.cpp
#include<stdio.h>
#include"client.h'"
void*Client::thread_func(void*pParm)
{
int i=*((int *)pParm);
printf("%d\n",i);
return (void*)0;
}
3.main.c
#include<stdio.h>
#include<pthread.h>
#include"client.h"
int main(void)
{
int i=6;
pthread_t thread_id;
pthread_create(&thread_id,NULL,thread_func,&i);
pthread_join(thread_id,NULL);
return 0;
}
main.c:8: 错误: ‘thread_func’ 在此作用域中尚未声明
大家给指点指点
从++
-
- 帖子: 448
- 注册时间: 2008-07-10 15:08
-
- 帖子: 448
- 注册时间: 2008-07-10 15:08
Re: 从++
windwiny, ?
不明白,是说我的头文件声明的不规范还是不正确,第一个不是头文件吗
不明白,是说我的头文件声明的不规范还是不正确,第一个不是头文件吗
-
- 帖子: 448
- 注册时间: 2008-07-10 15:08
Re: 从++
cissco,
老兄说的没错,我昨天响想的使用,若不定义为static类型的话用对象调用
Client client;
pthread_create(&thread_id ,NUll,client.thread_func,(void *)&i);
开来对c++掌握的还是不够熟悉,
我继续努力,大家共同进步
老兄说的没错,我昨天响想的使用,若不定义为static类型的话用对象调用
Client client;
pthread_create(&thread_id ,NUll,client.thread_func,(void *)&i);
开来对c++掌握的还是不够熟悉,
我继续努力,大家共同进步
-
- 帖子: 448
- 注册时间: 2008-07-10 15:08
Re: 从++
不回是来笑我的吧,从好学那你就好好学从吧