Executing a function at program's startup - TechRepublic
General discussion
October 15, 2003 at 03:23 PM
jp

Executing a function at program’s startup

by jp . Updated 22 years, 8 months ago

just a comment about the latest c++ tips from builder.com ‘Executing a function at program’s startup’, which recommends initialising a program in the constructor of a global object…

i avoid global objects like the plague. this is mainly because the order of their construction, and the context of their allocation, and various other things, is undefined by the language. i find its much more reliable to keep all data within the context of blocks of code.

to solve the problem here, i think its better to use a self initialising singleton with a static function to return a reference. what do people think?

jp

This discussion is locked

All Comments