The order of head .h file

We usually receive complaints come from the compiler that can find class definition included in the .h file. But we do add the head file in the corresponding cpp file. There does the complaint comes from?

 

To examine the problem, we need to go through the whole process of compile.

First the compiler compiles each of the CPP file into an objective code(.obj) individually, then all the obj file will be linked into an executable code(.exe).

 

Back to the question, though we add head file in the corresponding cpp file, the head file may be used in other cpp file, maybe the main dialog CPP file. The dialog CPP file will load all the head file by the include order. If an included head file uses some classes defined in other head file, we must put those head files ahead. So just go through all the place where the head file appeared, and include needed head files first, the problem will be solved.

 

When we design a head file,

1.      Avoid including other head file to make the head file simple and easy to use.

2.      Attention to the order of head files, and put the base head file first.

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值