It was a C++ interview,

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.


所有跟帖: 

why it needs a copy ctor? why make copy constructor "protected" -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (356 bytes) () 03/05/2009 postreply 11:50:35

the interviewer said -吴用先生- 给 吴用先生 发送悄悄话 (186 bytes) () 03/05/2009 postreply 12:31:48

ok. -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (0 bytes) () 03/05/2009 postreply 12:40:14

请您先登陆,再发跟帖!