Why do we need a `class` in C++, when a `struct` can be used to achieve the same?
c++, class, struct
Solution
You don't need classes, the language just gives you another option to choose from. Technically, you're right, you can achieve anything a `class` can do with a `struct`.
Besides the default access level, there's also the meaning most programmers associate with the two - `struct` generally means a light-weight, typically `POD`, data-type with little to no functionality. A `class` is usually associated with something bigger.
Problem
Using a `struct` we can achieve all the functionality of a `class`: constructors (that can be modified/overloaded), destructors (that can be modified/overloaded), operator overloading, instance methods, static methods, `public`/`private`/`protected` fields/methods. Why do we need `class` then? Note: I don't want the answer saying that in `struct`, fields/methods are `public` by default.