【发布时间】:2015-12-01 08:11:02
【问题描述】:
基本上,我有一个拥有另一个对象的类:
class A()
{
A() { initSystems() };
void initSystems();
B b;
}
class B()
{
B() { //Does stuff that requires 'initSystems()' to be called before }
}
为了使“B”起作用,需要在 A 中调用 init 系统函数。有什么“好”的方法可以解决这个问题吗?比如稍后创建“B”对象之类的?
【问题讨论】:
标签: c++ design-patterns dependencies