What are the differences between struct and class in C++?



The members and base classes of a struct are public by default, while in class, they default to private. Struct and class are otherwise functionally equivalent.

They are however used in different places due to semantics. a struct is more like a data structure that is used to represent data. class, on the other hand, is more of a functionality inclined construct. It mimics the way things are and work.


Advertisements