Notes

Thoughts, write-ups, and things worth remembering.

struct vs class

#cpp#oop Updated Sep 16, 2026

Functionally almost identical in C++ — the only real difference is the default access level.

struct Point { int x, y; };        // members default to public
class Point  { int x, y; };        // members default to private

Convention, not a hard rule

  • struct — a plain bundle of data, no invariants to protect, all fields meant to be poked at directly (vec3, a POD settings struct).
  • class — has behavior, hides its internals, enforces rules about how it can be used.

Nothing stops you from writing a struct with private members and methods, or a class with everything public — the compiler doesn’t care. This is purely a readability convention everyone agreed to follow.

Members and access control