Another class Bar which define a static member of class Foo: the Foo member is being initialized (but not constructed).
What's the best way to construct the static member, in other words where or how should I make sure the constructor is called on the static member?
Should I turn to singleton?
// In demo.h
class Foo {
Foo() {
// doing important stuff in there
}
};
class Bar {
static Foo foo;
};
// In demo.cpp
Foo Bar :: foo = Foo();
void main() {
Bar bar;
// bar.foo is not constructed yet. How to do that?
}
0 comments:
Post a Comment
Thanks