Exceptions
Team LiB
Previous Section Next Section

Exceptions

Get/set functions are useful, but a class consisting mostly of gets/sets is probably poorly designed: Decide whether it wants to provide an abstraction or be a struct.

Value aggregates (also called "C-style structs") simply keep a bunch of data together but do not actually add significant behavior or attempt to model an abstraction and enforce invariants; they are not meant to be abstractions. Their data members should all be public because the data members are the interface. For example, std::pair<T,U> is used by the standard containers to aggregate two otherwise unrelated elements of type T and U, and pair itself doesn't add behavior or invariants.

    Team LiB
    Previous Section Next Section