What are the differences between a class and a struct?
Show answer and explanation
class and struct have the same language capabilities. Their only built-in differences are defaults: members and bases are private for class, public for struct; conventionally structs model transparent data while classes protect invariants.
class and struct have the same language capabilities. Their only built-in differences are defaults: members and bases are private for class, public for struct; conventionally structs model transparent data while classes protect invariants.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.