我有一个类,要处理我之前创建的另一个类的对象数组(这个类已经可以正常工作)。问题出现在我尝试创建我的列表类的对象时。
这是列表类的头文件:
这是主要函数:
我的编译器报错如下:
错误:"27 \PersonList.h ISO C++ forbids declaration of `Personlist' with no type"
我已经搜索了答案,但由于我是C++的新手,有点困惑,还没有找到合适的答案。如果您能为我解释一下这个错误就太好了。
这是列表类的头文件:
#ifndef personlistH
#define personlistH
#include "Person.h"
#include <iomanip>
#include <iostream>
#define SIZE 10
namespace std {
class PersonList {
private:
Person persons[SIZE];
int arrnum;
string filename;
public:
Personlist();
};
}
#endif
这是主要函数:
#include <iostream>
#include "PersonList.h"
using namespace std;
int main() {
PersonList personlist;
return 0;
}
我的编译器报错如下:
错误:"27 \PersonList.h ISO C++ forbids declaration of `Personlist' with no type"
我已经搜索了答案,但由于我是C++的新手,有点困惑,还没有找到合适的答案。如果您能为我解释一下这个错误就太好了。