Bloomberg Interview Question

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

Interview Answers

Anonymous

Oct 5, 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).

Anonymous

Oct 11, 2011

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