c++ - 由于未声明的标识符,朋友功能将无法工作
问题描述
这是 Foo.hpp
#ifndef Foo_hpp
#define Foo_hpp
#include <stdio.h>
#include "Bar.hpp"
class Bar;
class Foo
{
private:
int z;
public:
void addY(Bar &x);
};
#endif /* Foo_hpp */
这是 Bar.hpp
#ifndef Bar_hpp
#define Bar_hpp
#include <stdio.h>
#include "Foo.hpp"
class Bar
{
private:
int y;
public:
friend void Foo::addY(Bar&);//use of undeclared identifier 'Foo'
};
#endif /* Bar_hpp */
我什至不知道为什么它一直给我这个错误,我尝试处理它并尝试查看我是否拼写错误或输入错误。我什至尝试从头开始重写所有内容,但仍然出现相同的错误。
解决方案
推荐阅读
- java - 在 Excel 工作表的列末尾写入 excel 数据
- bluetooth-lowenergy - 尽管我已配对,但 BLE 属性需要身份验证
- azure - 更改为不同的 Azure 订阅时,Azure PowerShell 脚本不起作用
- excel - Excel:CountIf RangeA 比 Range B 大 n 个单位
- python-3.x - 如何在字符串中打印python中的单个反斜杠?
- python - ImportError:没有名为 _shim 的模块
- c# - 从“double”到“System.Runtime.Serialization.ISerializable”的装箱转换
- macos - Visual Studio Docker HTTPS 设置失败
- html - 如何在不中断新行的情况下保持列网格?
- shopify - 起始页上的捐款柜台