Pergunta de entrevista da empresa Bloomberg

How to avoid having instances of your class created on the stack

Respostas da entrevista

Sigiloso

5 de out. de 2011

First Guess: Declare a private constructor, this should prevent the compiler from allowing it to be called during stack initialization (It should give a compile warning about an unavailable member). Of course, it can't be easily initialized on the heap either, so you'll have to provide a comparable member function (getInstance () or some such).

Sigiloso

11 de out. de 2011

Ryan you are going way too overboard with constructors. Declare static\global, or declare dynamically on the heap (new , malloc). That's it.