首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

error C2653: 'General' : is not a class or namespace name

2012-01-31 
求助:error C2653: General : is not a class or namespace name#include afx.h#include stdlib.h#i

求助:error C2653: 'General' : is not a class or namespace name
#include "afx.h"
#include <stdlib.h>
#include <iostream>
#include <winsock2.h>
#include <windows.h>
#include <math.h>
using namespace std;
CString General::GetIp()
{
CString ipStr="";
char szTempFile [MAX_PATH];
char szTempPath [MAX_PATH];
GetTempPath(MAX_PATH, szTempPath);  
UINT nResult=GetTempFileName (szTempPath, _T ("ip"),0,szTempFile);
int ret=URLDownloadToFile(NULL,"http://www.ip138.com/ip2city.asp",szTempFile,0,NULL);
if (ret==S_OK) //如果下载成功
{
FILE *f;
f=fopen(szTempFile,"rb");
if(f)
{
fseek(f,0,SEEK_END);//得到文件大小
int ilength=ftell(f);
fseek(f,0,SEEK_SET);
if(ilength>0)
{  
char szMyIp[16] = {0};
char fBuffer[256] = {0}; 
fread(fBuffer, 256, 1, f);
int iBegin,iEnd;

for (int i = 0; i < ilength; i++)
{
//取得"["的位置
if (fBuffer[i] == 0x5b)
iBegin = i;
//取得"]"的位置
if (fBuffer[i] == 0x5d)
{
iEnd = i;
break;
}
}
memcpy(szMyIp, fBuffer + iBegin + 1, iEnd - iBegin - 1);
//AfxMessageBox(szMyIp);
ipStr=szMyIp; 
}
}
}
}

int main()
{
GetIp();
return 0;
}

执行结果:
D:\新建文件夹 (2)\Text1.cpp(15) : error C2653: 'General' : is not a class or namespace name



[解决办法]
去掉General::
[解决办法]
'General' 不是一个类名 你在哪里定义的?
[解决办法]
General是什么 你没有定义吧!
[解决办法]
看下基础的C++书籍吧!!

热点排行