I’m not exactly certain what happens but take the following:
class A{
}
–
class B{
#include "A.h"
}
–
class C{
#include "B.h"
}
Now if I were to code in class C does it mean class A is also automatically included as well? From what I understand is that #include basically copies the entire file right on the spot.
Can anyone elaborate on this?
I’m trying to use class forwarding as much as I can. But sometimes I simply can not.
Edit:
The classes above are not in the same file. Imagine them separated.
Edit II:
Let me put it into more context.
Lets say I’m creating a new class that includes class B, but then I declare a variable of type A. This seems to compile even though I never included A to the class. Is this just how it goes in C++?
That would basically declare a nested class called A inside class
B.Cases where
includedirectives should be anywhere else other than the top of the file are very rare, and usually have completely different purpose than what you have.If I understood your file hierarchy correctly, it’s equivalent to: