分页: 1 / 1

从++

发表于 : 2008-10-13 16:46
weihua2008
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’ 在此作用域中尚未声明
大家给指点指点

Re: 从++

发表于 : 2008-10-13 22:03
windwiny
头文件在哪

Re: 从++

发表于 : 2008-10-14 10:25
weihua2008
windwiny, ?
不明白,是说我的头文件声明的不规范还是不正确,第一个不是头文件吗

Re: 从++

发表于 : 2008-10-15 11:00
自由建客
Client::thread_func

Re: 从++

发表于 : 2008-10-17 10:40
cissco
pthread_create(&thread_id,NULL,thread_func,&i);
改成:pthread_create(&thread_id,NULL,Client::thread_func,(void *)&i)

Re: 从++

发表于 : 2008-10-17 13:27
weihua2008
cissco,
老兄说的没错,我昨天响想的使用,若不定义为static类型的话用对象调用
Client client;
pthread_create(&thread_id ,NUll,client.thread_func,(void *)&i);
开来对c++掌握的还是不够熟悉,
我继续努力,大家共同进步

Re: 从++

发表于 : 2008-10-17 13:45
cnkilior
从++太复杂了,没心思学。还是从好。而且从++执行效率不如从,开发效率不如Java,从#!

Re: 从++

发表于 : 2008-10-17 16:03
weihua2008
不回是来笑我的吧,从好学那你就好好学从吧