jeudi 30 avril 2020

What do curly braces after a struct variable member mean?

During some maintenance (Valgrind'ing) I came across this code:

#pragma pack(push, 1)
struct somename
{
  uint16_t a{};
  uint16_t b{};
  uint32_t  c{};
};
#pragma pack(pop)

I would expect that the {} tell the compiler to always initialize the values to 0 (when allocating using new, or using a stack variable), but I cannot find any examples or documentation on that. Am I correct in this assumption? If not:

What do the curly braces {} after a struct member variable mean?

Aucun commentaire:

Enregistrer un commentaire