I have classes A, B and C.
A has members B and C.
C has data B wants to access.
I’m thinking of doing something like this, and would like to ask whether or not this is good design.
class A{
B* m_b;
C* m_c;
};
class B{
A* m_a; // so that i can get access to C->m_data
};
class C{
vector<Obj*> m_data;
}
How would you design class B?
Circular pointers are almost always a bad idea. You probably don’t need access to
C->m_datafrom the entire classB; just pass it as an argument to theBmethods that need to see it.