0

我有一个名为 Restaurant 的类,其中包含一个 Employee 成员。现在 Employee 是 Restaurant 的朋友班。当我尝试编译它时,我在 Employee mCurrentEmployee 上收到错误,说它缺少类型说明符 - 假定为 int。为什么编译器会为此生我的气?关于如何修复它的任何想法?谢谢。

#pragma once
#include "employee.h"
class Restaurant{
    friend class Employee;

private:
    Employee mCurrentEmployee;

};

-

#pragma once
#include "restaurant.h"
class Employee {

}
4

1 回答 1

2

如果您从员工中删除应该解决朋友问题的includeof "restaurant.h"(您可能需要使用前向声明来编译代码,但鉴于您向我们展示的最少代码,无法确定)。

也就是说,您应该问自己为什么员工首先需要成为餐厅的朋友。

于 2015-04-23T00:26:11.333 回答