合成错误不知道为什么会发生这种情况,请检查一下并告诉我这是我的编码还是视觉工作室

Composition error no idea why this happens please check it out and tell me if it was my coding or visual studio

本文关键字:一下 工作室 告诉我 编码 我的 视觉 检查 为什么 不知道 错误 情况      更新时间:2023-10-16

https://i.stack.imgur.com/mwuYZ.jpg

严重性代码描述项目文件行 错误 C2061 语法错误: 标识符"生日"项目1 c:\users\win7\documents\Visual Studio 2017\项目\项目1\项目1\人员.h 12 错误 C3646"出生日期":未知覆盖说明符 项目1 c:\users\win7\documents\Visual Studio 2017\projects\project1\project1\people.h 16 错误 C4430 缺少类型说明符 - 假定为 int。注意:C++不支持默认的 int Project1 c:\users\win7\documents\visual studio 2017\projects\project1\project1\people.h 16 错误 C2661 'People::P eople':没有重载函数需要 2 个参数 项目1 c:\users\win7\documents\Visual Studio 2017\项目\项目1\项目1\main.cpp 8 错误 C2061 语法错误: 标识符"生日"项目1 c:\users\win7\documents\Visual Studio 2017\项目\项目1\项目1\人员.h 12 错误 C3646"出生日期":未知覆盖说明符 项目1 c:\users\win7\documents\Visual Studio 2017\projects\project1\project1\people.h 16 错误 C4430 缺少类型说明符 - 假定为 int。注意:C++不支持 default-int Project1 c:\users\win7\documents\visual studio 2017\projects\project1\project1\people.h 16

你不需要在Birthday.h中包含People.h,因为class Birthday根本不依赖于class People

编译器抱怨的是,它首先看到People的定义。People有一个成员Birthday dateofbirth。但在这一点上,class Birthday尚未定义。

如果你真的需要以某种方式让Birthday也依赖于People,你将创建一个循环依赖,这在C++是不可能的。