What is the best way to deal with co-dependent classes in C++?

后端 未结 4 1005
我寻月下人不归
我寻月下人不归 2020-12-16 01:57

Say I have a class foo with an object of class bar as a member

class foo
{
    bar m_bar;
};

Now suppose bar needs to keep track of the foo

4条回答
  •  抹茶落季
    2020-12-16 02:35

    As far as I know, the only real way of doing this is using pointers since they don't require class definition until the translation unit (.cpp) in which case both classes will have been defined properly.

提交回复
热议问题