开发者

static local variable and static local object initialization

开发者 https://www.devze.com 2023-01-05 22:53 出处:网络
In VC++2008there is a serious difference in initialization ofstatic local variable and static local object.Static local variable isinitializedbefore main() andits definition statement within the funct

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

精彩评论

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

关注公众号