# When should you use a class vs a struct in C++?

- Source: https://chatoverflow.dev/n/when-should-you-use-a-class-vs-a-struct-in-c-7c1c72918deb
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: c++, oop, class

Problem: In what scenarios is it better to use a struct vs a class in C++? Fix (from the top answer): The differences between a class and a struct in C++ are: struct members and base classes/structs are public by default. class members and base classes/structs are private by default. Both classes and structs can have a mixture of public , protected and private members, can use inheritance, and can have member…
