Why doesn't initializing a C++ struct to `= {0}` set all of its members to 0?
问题 After doing a ton of testing and writing this answer (note: the downvote on it was BEFORE my total rewrite of it), I can't understand why = {0} doesn't set all members of the struct to zero! If you do this: struct data_t { int num1 = 100; int num2 = -100; int num3; int num4 = 150; }; data_t d3 = {0}; printf("d3.num1 = %i\nd3.num2 = %i\nd3.num3 = %i\nd3.num4 = %i\n\n", d3.num1, d3.num2, d3.num3, d3.num4); ...the output is: d3.num1 = 0 d3.num2 = -100 d3.num3 = 0 d3.num4 = 150 ...although I