免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2668 | 回复: 2
打印 上一主题 下一主题

[函数] 静态函数内部不能用类声明对象? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-26 11:39 |只看该作者 |倒序浏览
源代码如下:

void* COCIConnPool::thMaintain( void* pParam )
{
        COCIConnPool*          pObj= (COCIConnPool*)pParam;             //对象指针
        unsigned int           iCount= 0;

        pthread_detach( pthread_self() );

        printf( "COCIConnPool maintain thread [%d:%d] start up !\n", (INT32)getpid(), (INT32)pthread_self() );

        while ( pObj->m_cInitFlag )
        {
                usleep( 500 );
                iCount++;

                if ( iCount % 20 == 0 )  //10秒钟做一次维护操作
                {
                        pObj->MaintianConnection();
                }

        }//while ( !pObj->m_cInitFlag )

        printf( "COCIConnPool maintain thread [%d:%d] exit !\n", (INT32)getpid(), (INT32)pthread_self() );

        return 0;
}

编译的时候报:
OCIConnPool.cpp: In function `static void * COCIConnPool::thMaintain(void *)':
OCIConnPool.cpp:321: invalid use of type decl `class COCIConnPool' as expression
OCIConnPool.cpp:321: `pObj' undeclared (first use this function)
OCIConnPool.cpp:321: (Each undeclared identifier is reported only once
OCIConnPool.cpp:321: for each function it appears in.)
OCIConnPool.cpp:321: invalid use of type decl `class COCIConnPool' as expression
OCIConnPool.cpp:321: parse error before `)'

不解为什么会报这个错误.

gcc 2.95.3

论坛徽章:
0
2 [报告]
发表于 2006-08-26 13:53 |只看该作者
怎么没有人回答我啊!急,在线等.

论坛徽章:
0
3 [报告]
发表于 2006-08-26 14:10 |只看该作者
已经解决了.

因为编译器的不同,
需要在类名前面加class!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP