
6 May
2005
6 May
'05
1:07 p.m.
I'm a little confused about singleton usage. Can a singleton have a constructor? I tried this: using boost::basic_singleton; struct Example : public basic_singleton<Example> { Example() { std::cout << "Hello\n"; } int Cnt() const { return 0; } }; int main() { Example::pointer ptr; std::cout << ptr->Cnt(); } ./Test1 0 It appears constructor wasn't run, because nothing was printed.