> It is up to the constructor to only initialize storage, or do whatever it feels like to have values assigned to it.
Right, see the "I guess the argument might be" part above... I find this to be a very questionable design choice, leaving you to have to go and read a header somewhere to determine whether `Foo f;` is safe or not. But it's not really a choice, is it? C++ had to do it this way to be compatible with how C programs were written back in the 1970s.
> By the way, already in the 16 bit days you could configure to have warnings as errors for variables being used without initialisation.
Ah yes, the "but C can be configured to be not-insane" argument, one of my favorite pjmlp-isms, right up there with "but $LANG's compiler is written in C++" and "but you already get memory safety with a GC". Keep on doing you!
Thus a default constructor replicates a plain int x;, whereas the copy constructor or single value constructor is used for int x = 42;.
By the way, already in the 16 bit days you could configure to have warnings as errors for variables being used without initialisation.
Replies (1)
Right, see the "I guess the argument might be" part above... I find this to be a very questionable design choice, leaving you to have to go and read a header somewhere to determine whether `Foo f;` is safe or not. But it's not really a choice, is it? C++ had to do it this way to be compatible with how C programs were written back in the 1970s.
> By the way, already in the 16 bit days you could configure to have warnings as errors for variables being used without initialisation.
Ah yes, the "but C can be configured to be not-insane" argument, one of my favorite pjmlp-isms, right up there with "but $LANG's compiler is written in C++" and "but you already get memory safety with a GC". Keep on doing you!