缺少“;”(在“namespace”的前面)这个是什么问题?

来源:百度知道 编辑:UC知道 时间:2024/05/26 03:42:15
程序如下:
#include "stdafx.h"
#include "ManageStudent.h"
#include "Student.h"
#include <iostream>

using namespace std;

CManageStudent*pBase;

int main()
{
pBase=new CManageStudent;
if(pBase->InitialData()){
int ID;
while(1){
pBase->ShowMenu();
cin>>ID;
pBase->DoEvent(ID);
}
}
delete pBase;
system("pause");
return 0;
}
不要说太多,有什么问题,该怎么改,说重点!~

头文件的顺序应该没关系,
如果有关系的话,出现的错误不可能就这个的

我想可能是你自己写的那个头文件缺少分号,
比如类定义最后那个分号,检查下

尝试把头文件的顺序换一下,像这样

#include "stdafx.h"
#include <iostream>
using namespace std;

//最后才包含自己的头文件
#include "ManageStudent.h"
#include "Student.h"

如果还会出现错误,但是这次是在"CManageStudent*pBase; "之前缺少"; ",证明你的头文件里有些语句没有写分号。注意,是语句,可能是变量的定义,函数的声明,或者是像"using namespace xxx;"之类的。