Will there be a class override if the class is indirectly included through two include files?

if I include classA.h and classC.h in class, then if classD.h includes both classB.h and classC.h, will there be a class override?

+5
source share
1 answer

If you use correctly enable guards , this should not be a problem. In particular, if you make sure that #include-in the same file is idempotent twice (-the #includesame header is twice the same as #include-th its once), this will not cause a problem. When classD.hincluded classB.h, it will include classA.h. Then, when he tries to turn it on classC.hand classC.htries to turn it on classA.h, nothing happens. This is beautiful because it classC.hcan see classA.h, because it is already on.

+5
source

All Articles