C++ Structure Initialization -


is possible initialize structs in c++ indicated below

struct address {     int street_no;     char *street_name;     char *city;     char *prov;     char *postal_code; }; address temp_address =     { .city = "hamilton", .prov = "ontario" }; 

the links here , here mention possible use style in c. if why not possible in c++? there underlying technical reason why not implemented in c++, or bad practice use style. using way of initializing because struct big , style gives me clear readability of value assigned member.

please share me if there other ways through can achieve same readability.

i have referred following links before posting question

  1. c/c++ aix
  2. c structure initialization variable
  3. static structure initialization tags in c++
  4. c++11 proper structure initialization

if want make clear each initializer value is, split on multiple lines, comment on each:

address temp_addres = {   0,  // street_no   nullptr,  // street_name   "hamilton",  // city   "ontario",  // prov   nullptr,  // postal_code }; 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -