3 ms·
You are missing that such struct initialization did not exist when C with Classes came to be. Additionally, you are missing the whole package of struct semanti
by pjmlp 2y ago
You are missing that such struct initialization did not exist when C with Classes came to be.
Additionally, you are missing the whole package of struct semantics in C++, that while they should at naked eye still look like C structs, they have to also support C++ struct semantics, of memory construction, copy assignment and bitwise comparisaion.
Hence why structs and classes are the same, with the difference that structs are public by default, with code generated for keeping the bitwise C semantics, until any of those operations are redifined, at which point the compiler leaves out the job to the developer.
- senkora 2y agoThank you for the response. I still don’t understand why it would be necessary for C++ to default to non-explicit constructors when C at the time did not have constructors and did not have constructor-like struct initialization that mimicked non-explicit constructors. It seems like an unforced error in the language design, rather than a concession to backwards-compatibility.