title: How to initialize a struct to 0 in C++
body: <p>Here is a related C answer that doesn't work (as a zero initializer for a struct) in C++: <a href="https://stackoverflow.com/questions/11152160/initializing-a-struct-to-0">Initializing a struct to 0</a>. One of the solutions presented is this:</p>
  <pre><code>myStruct _m1 = {0}; 
  </code></pre>
  <p>This works fine in C, but it doesn't work in C++. :( :</p>
  <blockquote>
  <p>error: cannot initialize a member subobject of type 'myScope::MyStruct' with an rvalue of type 'int'`.</p>
  </blockquote>
  <p>How do you zero-initialize a struct in C++?</p>
  <h2>Related:</h2>
  <ol>
  <li>Initializing
  a struct to 0 in C: <a href="https://stackoverflow.com/questions/11152160/initializing-a-struct-to-0">Initializing a struct to 0</a></li>
  <li>Update: (an adjacent, but NOT duplicate question which also turns out to be very useful) <a href="https://stackoverflow.com/questions/51862128/initialization-with-empty-curly-braces">Initialization with empty curly braces</a></li>
  </ol>
  <h2>See also:</h2>
  <ol>
  <li>[adjacently-related, but is for C-style arrays, <em>not</em> structs] <a href="https://stackoverflow.com/a/201116/4561887">How to initialize all members of an array to the same value?</a></li>
  </ol>
  <h2>To the people voting to close this question:</h2>
  <p>My question is not a duplicate of this other question (<a href="https://stackoverflow.com/questions/51862128/initialization-with-empty-curly-braces">Initialization with empty curly braces</a>), as this other question isn't asking about the various ways to initialize a struct in C++ and why the C way doesn't work, rather, they are asking <strong>why does the C++ keyword <code>explicit</code> break one of their initialization techniques</strong>. Two distinct questions. Not duplicate.</p>
  <h2>Follow-up question I asked:</h2>
  <ol>
  <li><a href="https://stackoverflow.com/q/61531928/4561887">Why doesn't initializing a C++ struct to <code>= {0}</code> set all of its members to 0?</a></li>
  </ol>