I have the following situation:
3 C++ Classes:
ClassA ClassB ClassC
class A
{
int member;
B bmember;
};
class B
{
int member;
std::shared_ptr <A> amember;
C cmember;
};
class C
{
int member;
std::shared_ptr <A> amember;
};
Each class implements functions that use the public member functions of the of other class. The file structure is as follows:
class1.cpp, class1.hpp includes class2.hpp
class2.cpp, class2.hpp includes class3.hpp and class1.hpp
class3.cpp, class3.hpp includes class1.hpp
Using #pragma once
in each header file saves me from having an infinite recursive loop. I am building a cmake project that builds each class into a library. They each target eachother.
However because there are no forward declarations of ClassB to ClassA I receive "not declared errors"
I need each class to have a reference to the others, and still be able to access their functions. How can I achieve this? I am willing to merge files if I need too, but I would like to make the libraries modular and not all in one file.