Я пытался включить структуру с именем "student" в файл student.h
, но я не совсем уверен, как это сделать.
Код моего student.h
файла полностью состоит из:
#include<string>
using namespace std;
struct Student;
, в то время как файл student.cpp
полностью состоит из:
#include<string>
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 ++) не распознает struct Student из "student.h"?
Как я могу объявить struct Student в "student.h", чтобы я мог просто #include "student.h" и начать использовать struct?