Answer
In C++, struct and class define the same kind of class type. • A struct defaults to public member access and public base inheritance. • A class defaults to private member access and private base inheritance. • Both can have constructors, destructors, methods, templates, and virtual functions.
💡 C++ Example
struct Point { int x; int y; };
class Counter {
public:
void increment() { ++value_; }
private:
int value_{};
};
⚡ Quick Revision
struct and class differ mainly in their default access and inheritance.