Search This Blog

Friday, October 2, 2009

C++, Why Static Memeber in Singleton?

a static member can be of the same class type as that of which it is a member. A nonstatic data member is restricted to being declared as a pointer or reference to an object of its class. C++ primer, p645, 3rd

class Bar {

static Bar mem1; //ok
Bar *mem2; //ok
Bar mem3; //error

a singleton example

No comments: