Reduce the number of #include files in header files. It will reduce build times. Instead, put include files in source code files and use forward declarations in header files.
我在这里阅读。http://www.yolinux.com/TUTORIALS/LinuxTutorialC++CodingStyle.html。
因此它说如果头文件中的类(类A)不需要使用某个类(类B)的实际定义。那时我们可以使用前向声明,而不是包括特定的(B类)头文件。
问题:如果标头中的类(类A)没有使用特定类(类B)的实际定义,那么正向声明如何帮助减少编译时间?
vehicle.h,bus.h,toybus.h。vehicle.hinclude bybus.h和bus.hinclude bytoybus.h。所以如果我做一些改变bus.h。编译器是否打开并vehicle.h再次解析 ?它会再次编译吗?