Hypothetical situation that I'm struggling to get my head past.
HoldsFooBar.h:
#include "foo.h"
#include "bar.h"
class HoldsFooBar{
foo F;
bar B;
};
foo.h:
//includes?
class foo{
HoldsFooBar *H;
void Baz();
};
bar.h:
//includes?
class bar{
HoldsFooBar *H;
void Qux();
};
I'm trying to get F to get a hold of B. In all other languages I've worked with, I would be able to H->B.Qux();
, but I'm totally lost in C++. At the includes lines in foo.h
and bar.h
, it seems like my options are to forward-declare class HoldsFooBar;
but then I can only access H, and F and B cannot see each other. Likewise, I can #include "HoldsFooBar.h"
but because of my include guards, something ends up not getting linked properly, so the program doesn't run.
Is what I'm trying to do even possible? Thank you very much! Any help would be appreciated!