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.

Updated on: 30-Jul-2019


Kickstart Your Career

Get certified by completing the course

Get Started