Proper way to initialize C++ structs

后端 未结 6 519
误落风尘
误落风尘 2020-12-07 08:11

Our code involves a POD (Plain Old Datastructure) struct (it is a basic c++ struct that has other structs and POD variables in it that needs to get initialized in the beginn

6条回答
  •  -上瘾入骨i
    2020-12-07 08:56

    Since it's a POD struct, you could always memset it to 0 - this might be the easiest way to get the fields initialized (assuming that is appropriate).

提交回复
热议问题