#ifndef __COMOPRE__
//----------------TComOpre.h
#define __COMOPRE__
class TComOpre
{
public:
HANDLE hd_com1,hd_com2; BOOL opencom(int port);
static CString getvalue();};#endif __COMOPRE__//----------------TComOpre.cpp
#include "stdafx.h"
#include "ComOpre.h"
BOOL TComOpre::opencom(int port)
{
return true;
}static CString getvalue()
{
return "xxx";
}
//----------------------
xxxx.cpp
#include "TComOpre.h"
....
void CMy008Dlg::Onopen1()
{ CString aa;
aa = TComOpre.getvalue();
}
编译结果如下
------------------------------------------------------------------
--------------------Configuration: 008 - Win32 Debug--------------------
Compiling...
008Dlg.cpp
D:\XJ_Work_Station\test\1127\008\008Dlg.cpp(133) : error C2275: 'TComOpre' : illegal use of this type as an expression
d:\xj_work_station\test\1127\008\comopre.h(5) : see declaration of 'TComOpre'
执行 cl.exe 时出错.008.exe - 1 error(s), 0 warning(s)
解决方案 »
- 如何实现矩形慢慢消失
- 将一个十六进制数放入字符数组里
- 用VC遇到问题,请问大家碰到过没
- 如何在主程序加载之前出现一个等待对话框
- 请问如何查看用vc写的ocx的源代码呢?
- 你是高手吗?想要分吗?进来吧!如何控制鼠标的问题,急!!!
- 用WriteFile()写串口不成功的问题。。。
- vc++ 2005 想要按下按鈕後..在按鈕下新鍵預設的畫面.要怎做?
- 调用CreateService(...)不成功的奇怪问题。
- 到哪能找到VToolD,QuickVxd ?
- HELP!使用winInet进行HTTP上传下载时如何通过ISA SERVER的代理?(100分)
- Assertion Failed 问题的困扰, delete pTermData(删除指针),具体代码如下,求助!!!
{
return "xxx";
}
--------------------Configuration: 008 - Win32 Debug--------------------
Compiling...
ComOpre.cpp
D:\XJ_Work_Station\test\1127\008\ComOpre.cpp(11) : error C2724: 'getvalue' : 'static' should not be used on member functions defined at file scope
执行 cl.exe 时出错.
Creating browse info file...008.exe - 1 error(s), 0 warning(s)
{
return "xxx";
}
CString TComOpre::getvalue()
{
return "xxx";
}
to ringphone(临风)
为什么在函数申明时要加static,但在具体函数的地方却不用加
CString TComOpre::getvalue()在调用时要这样
void CMy008Dlg::Onopen1()
{ CString aa;
- aa = TComOpre.getvalue();
+ aa = TComOpre::getvalue();
}