I know there are many answers on this site about circular dependency, but none that I found can solve my problem, mainly because my definitions are inlined in the headers.
I am writing a library in C++11. For simplification, I have two classes:
ExceptioninException.hppCallStackinCallStack.hpp.
The dependencies are:
Exceptionmakes heavy use ofCallStack(both in declarations and definitions it needs a complete type ofCallStack) soException.hppincludesCallStack.hpp.CallStackdoesn't needExceptionat all in it's declaration. It just needs to throw anException(calls a non-defaultExceptionconstructor) in one of the member definition (operator[]), so it needs a complete type ofExceptionin a definition.
I know that if I write the definition in a .cpp file, I resolve the problem, but since all methods and constructors don't have more than 2 lines, I have chosen to define them inline, which means that they need to be defined in the .hpp header.
The solution to have a forward declaration before the declaration and to include the other header between the declaration and the definition doesn't work, as, I have said, Exception needs a complete type of CallStack in its declaration.