Understanding class vs struct in C++ interviews
This foundational C++ language question tests whether a candidate understands the subtle but important distinctions between two constructs that are nearly identical under the hood. Quant firms ask this to verify that you grasp both the technical differences and the conventions that guide when to use each one in production code.
The answer requires you to articulate several layers: the default access specifiers, inheritance rules, and how aggregate initialization behaves differently. Beyond the mechanics, interviewers are listening for whether you understand the intent behind choosing one over the other — that is, what signal you send to other engineers when you pick a struct versus a class in a codebase.
- Default member and inheritance access levels
- Aggregate initialization and trivial types
- Conventions around data representation versus encapsulation
- Memory layout and the C struct legacy