From a design perspective, one could have added the class
keyword to C++ to realize the desired OO principles like encapsulation, inheritance, polymorphism as well as constructors and destructors etc ... but at the same time leave the keyword struct
just like it is defined in C and thus be able to a) compile legacy C code and b) define simple PODs.
I cannot see the reason for making a struct
behave (almost) like a class
in C++.
Or in other words: Why didn't they just leave the C struct
keyword alone in C++?
Any hints ?
I cannot see the reason for making a struct behave (almost) like a class in C++.
One of the reason - provide ability to inherit from a struct
adding constructor/destructor etc and still it can be passed to C functions as C structure.