Initializing an object to all zeroes

后端 未结 12 585
离开以前
离开以前 2020-12-03 01:27

Oftentimes data structures\' valid initialization is to set all members to zero. Even when programming in C++, one may need to interface with an external API for which this

12条回答
  •  無奈伤痛
    2020-12-03 02:03

    some_struct s = { 0 }; is guaranteed to work; memset relies on implementation details and is best avoided.

提交回复
热议问题