【发布时间】:2015-02-03 01:34:48
【问题描述】:
我需要包含递归类头文件。
“Foo.h”
#ifndef FOO_H
#define FOO_H
#include "Bar.h"
class Foo {
public:
Bar* barMember;
};
#endif
"Bar.h"
#ifndef BAR_H
#define BAR_H
#include "Foo.h"
class Bar {
public:
Foo* fooMember;
};
#endif
在这种情况下,我会遇到类似
的错误'class' 没有命名类型
考虑在这种情况下Foo 是主类,它包含许多其他类作为成员。但是对于一个成员,我需要进行双向连接。
那我为什么会有这样的问题呢?
【问题讨论】:
标签: c++ unix recursion header-files