可能重复:
What is the purpose of forward declaration?
Forward Declaration vs Include的.h文件包含在头文件和cpp文件
我有点困惑,在页眉和自备电厂的#include *.h
文件包含文件。我看到一些.h文件被包含在头文件中,一些在相应的cpp文件中。我猜测所有需要的.h文件都需要包含在头文件中,因此没有看到它们被包含在cpp文件中的原因。这有什么特别的原因吗?
此外,我看到使用Class ClassName;
的头文件中包含了一些所需的类。这与在头文件中仅包含ClassName.h
有什么不同?
[前向声明的目的是什么?](http://stackoverflow.com/questions/3110096/what-is-the-purpose-of-forward-declaration),[Forward Declaration vs Include] (http://stackoverflow.com/questions/3632818/forward-declaration-vs-include),[前进声明/何时最好包括标头?](http://stackoverflow.com/questions/10469531/forward-declaration-什么时候最好包含头文件),[前向声明有什么缺点?](http://stackoverflow.com/questions/9470961/what-are-the-drawbacks-of-forward-declaration) – 2012-08-09 01:56:50