It was a C++ interview,

來源: 2009-03-05 10:44:10 [舊帖] [給我悄悄話] 本文已被閱讀:

and I implemented Singleton by declaring the constructor as protected, and use a static pointer of the same class as a member, which is "new"ed and returned by another public static method (this public method checks if the static pointer member is NULL and then decides whether to "new" or not).

The interviewer agreed my idea but pointed out besides the constructor, I also need to make copy constructor "protected", which I didn't do it.