如何包括头文件 [英] How do I include header file
问题描述
我有一个数据包类和一个数据包类。
在数据包工厂类中包含packet.h文件,在数据包类中包含packetfacotry.h文件。 / p>
然后,我在packetfactory.h文件中收到一个错误数据包不命名类型。
提前感谢。
方法:
首先,您可以在packetfacotry中使用 #includepacket.h
#includepacketfacotry.h。
其次,如果你有一个循环包含juste add class packet;
您的packetfacotry.h。文件或反之亦然
它声明预处理器的符号。
那么?
I have a packet class and a packetfactory class.
In packet factory class it includes packet.h file and in packet class it includes packetfacotry.h file.
Then I am getting an error "packet does not name a type " in packetfactory.h file.
How do I fix this?
Thanks in advance.
2 ways :
First, you can #include "packet.h"
in packetfacotry and #include "packetfacotry.h"
. DO NOT forget to protect your headers.
Second, if you have an circular inclusion juste add class packet;
in your "packetfacotry.h. file or vice versa.
It declares symbols for preprocessor.
So ?
这篇关于如何包括头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!