LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What's the difference between struct and class in C++?

They're identical except for the default access level: struct members are public by default, class members are private.

struct class
Default member access public private
Default inheritance public private
struct Point {
    int x, y;        // public by default
};

class Point {
    int x, y;        // private by default
public:
    // must explicitly expose anything callers need
};

In practice (convention, not a language rule):

  • Use struct for simple data bundles (like C structs)
  • Use class for types with behaviour and encapsulated state

Tip: Technically a struct can do everything a class can — inheritance, methods, access specifiers, the lot. The only real difference is the default.

From Quiz: REVE1 / C++ Programming | Updated: Jul 14, 2026