Skip to content

Class vs struct

Martin Jean-Christio edited this page Oct 25, 2022 · 1 revision

The differences between a class and a struct in C++ is:

class:

  • class members and base classes/struts are private by default.
  • use class when you make use of features such as private or protected members, non-default constructors and operators, etc.

struct:

  • struct members and base classes/structs are public by default.
  • use struct for plain-old-data structures without any class-like features;
Clone this wiki locally