Hello i'm trying to make my own library. im using qt creator. I've searched online and the best way to do one would be to use nested classes. The problem is the code below works fine in single file, but i'd like to seperate it into different files
example code:
To do that i'd want to make seperate .h and .cpp files for eg every class.
thus my class A header needs include header for B. but to connect B to A, in class B i need to do A::B which requires me to include header A as well. So in short both files need to include each other, but that in tern gives an error. Is there a way around this? or maybe im doing it all wrong. Thank you for the help in advance. If any more info is needed please ask away.
example code:
Code:
class A { public: class B { public: class C { public: }; class D { public: }; }; };
Code:
//headerA #include "B.hpp" class A { public: class B; }; //headerB #include "A.hpp #include "C.hpp" #include "D.hpp" class A::B { public: class C; class D; }; //headerC #include "B.hpp" class A::B::C { public: }; //headerD #include "B.hpp" class A::B::D { public: };
Comment