c++ - Initializing the first element in a struct -


I do a lot of Win32 programming in C ++ and in many Win32 structures, a 'size' (often cbSize or length ) member must be set as the first entry Which can be done before related API calls. For example:
  Windows Webpages Wp; Wp.length = sizeof (windowopen); Gatewindo placement (HWND, and YP);   

Now, I think that this is a good practice for starting the structure to zero. I:

  WINDOWPLACEMENT wp = {} ;   

or

  Windows Web site {0};   

However, if I start the first member like this, then what happens to the other members of the structure:

  WINDOWPLACEMENT wp = {sizeof (WINDOWPLACEMENT)};   

Do they automatically start at zero? Or is it using which compiler and does it depend on whether or not the debug builds?

Yes, they automatically start at zero.

8.5.1 / 7:

If there are fewer initials in the list, then there are members in total, then each member will not be explicitly starting the price-initial (8.5). [Example:

  straight s {int a; Four * b; Int c; }; S ss = {1, "asdf"};   

1, starts ss.a with "asdf" with ssb, and with the value of ss.c form int (), i.e., 0 .]

Comments