gpt4 book ai didi

c++ - VS2019 C++ 未知覆盖说明符

转载 作者:行者123 更新时间:2023-11-28 01:14:08 25 4
gpt4 key购买 nike

我在使用 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;
}

编译此文件时出现以下错误:

  1. “名称”:未知覆盖说明符缺少类型说明符 - int假定。
  2. 注意:C++不支持default-int

有人可以教我如何解决这个问题吗?

最佳答案

struct Name 在您尝试使用它时尚未定义。在定义 struct Person 之前定义 struct Name

关于c++ - VS2019 C++ 未知覆盖说明符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59262797/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com