As optimization, or to avoid including a loop, the type can be declared forward, this leads to the following code:
class A; class B { A *a; };
If the number of forward ads becomes large, it can take up a lot of space at the top of the header file. Is there a way to move forward and use at the same time? Example:
class B { extern A *a; };
I have never thought about this before, but I have a header with a bunch of forward declarations, and I would like to make it more accurate (without a farm in another include file).
EDIT: I changed "a" to a pointer, as it was correctly pointed out that you can only use forward declare for pointers and references.
source share