我一直在尝试在student.h文件中包含一个名为“student”的结构,但我不太清楚如何做.
我的student.h文件代码完全包括:
#include
using namespace std;
struct Student;
而student.cpp文件完全包含:
#include
using namespace std;
struct Student {
string lastName, firstName;
//long list of other strings... just strings though
};
不幸的是,使用#include“student.h”的文件会出现诸如此类的错误
error C2027: use of undefined type 'Student'
error C2079: 'newStudent' uses undefined struct 'Student' (where newStudent is a function with a `Student` parameter)
error C2228: left of '.lastName' must have class/struct/union
看来编译器(VC)不能从“student.h”中识别struct Student?
如何在“student.h”中声明struct Student,以便我可以#include“student.h”并开始使用struct?