开发者

static local variable and static local object initialization

In VC++2008 there is a serious difference in initialization of static local variable and static local object. Static local variable is initialized before main() and its definition statement within the function is skipped. Static local o开发者_StackOverflow社区bject is initialized by 0 value before main() and its definition statement within the function is executed only once . Constructor is started and object is initialized by appropiate value. All that can be seen in Debug mode. Does this solution correspond to the existing C++ Standard?


From http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf :

Every object of static storage duration shall be zero-initialized at program startup before any other initialization takes place. [ Note: in some cases, additional initialization is done later. —end note ]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜