The members and base classes of a
publicby default, while in
class, they default to
private. Note: you should make your base classes explicitly
protected, rather than relying on the defaults.
classare otherwise functionally equivalent.
Enough of that squeaky clean techno talk. Emotionally, most developers make a strong distinction between a
structsimply feels like an open pile of bits with very little in the way of encapsulation or functionality. A
classfeels like a living and responsible member of society with intelligent services, a strong encapsulation barrier, and a well defined interface. Since that’s the connotation most people already have, you should probably use the
structkeyword if you have a class that has very few methods and has
publicdata (such things do exist in well designed systems!), but otherwise you should probably use the