October 2004
Intermediate to advanced
240 pages
6h 22m
English
Know thyself: There are different kinds of classes. Know which kind you are writing.
Different kinds of classes serve different purposes, and so follow different rules. Value classes (e.g., std::pair, std::vector) are modeled after built-in types. A value class:
• Has a public destructor, copy constructor, and assignment with value semantics.
• Has no virtual functions (including the destructor).
• Is intended to be used as a concrete class, not as a base class (see Item 35).
• Is usually instantiated on the stack or as a directly held member of another class.
Base classes are the building blocks of class hierarchies. A base class:
• Has a destructor that is public and virtual ...