This answer is just a scratch on the surface of the inheritance
concept of OOP
and it does not cover all its aspects. You should read a book about C++
(or about OOP
in general) to get a complete answer.
The part struct otherStruct : public someStruct
says that otherStruct
extends someStruct
with public
inheritance. In simple words, public inheritance does not change the visibility of the members (properties and methods) inherited from the base class.
The declaration block of the new struct ({}
) is empty. It does not add any new members to those inherited from struct someStruct
.
If you compare someStruct
and otherStruct
by their memory footprint and behaviour, they are identical. But they are different types and they cannot be replaced one for the other.
However, a pointer to a variable of type otherStruct
can be used where a pointer to struct someStruct
is expected (because otherStruct
, by extending someStruct
has all the properties expected from someStruct
) but the other way around is not possible.