我在使用VS2019编译C++代码时遇到困难。
我有Person.h头文件:
#ifndef PERSON_H
#define PERSON_H
#include <string>
using namespace std;
namespace PersonClass {
struct Person {
public:
Name name;
int age;
};
struct Name {
public:
string firstName;
string lastName;
};
}
#endif
这是我的main.cpp:
#include "pch.h"
#include <iostream>
#include "Person.h"
using namespace std;
int main()
{
return 0;
}
当我编译该文件时,出现以下错误:
假定。
有人可以教我如何解决此问题吗?
最佳答案
尝试使用struct Name
时尚未定义。在定义struct Name
之前,先定义struct Person
。