The compiler must know the exact layout of the object by looking at the header file in which it is defined.
Your code says that the MyQueue class has a member of type InnerQueue , which will be part of the memory layout of MyQueue objects. Therefore, to display the MyQueue memory MyQueue he needs to know the InnerQueue memory InnerQueue . That this is not so because you say "well, it is defined elsewhere."
What you are trying to do is closely related to the " PIMPL idiom " / "firewall compiler".
To solve the problem, you must either include HiddenQueue.h in your header or declare _innerqueue as a pointer:
class myQueue { public: myQueue(); private: inner::HiddenQueue* _pinnerQueue; };
Using a pointer is possible because the pointer has a known memory size (depending on your target architecture), so the compiler does not need to see the full HiddenQueue .
source share