What Classes We Design and How

By Peter Sommerlad

C++ class design has been error prone since the beginning until Scott Meyers told us about the Rule-of-Three. But even that safety rule is not enforced by the language. In addition, C++11 changed the set of compiler-provided special member functions and the intrinsic rules have become more complicated. However, instead of starting from the rules for special member functions, we will look at what role a C++ object plays and how that maps on what special member functions to define for its class and how, if any. Examples for object roles are Value, Relation, Manager (scoped, unique, general) and Subject(identity). Note, an individual object or its type can actually play several of those roles.

We will rehearse the Rule of Zero, and learn more about the Rule of Five/Six, the Rule of DesDeMovA, and the new Rule of (Unique) Three.

This all will enable you to much more consciously and safely design your class types and combine types of member variables.

As an extra we will look at relation objects that allow "Fernwirkung" in expressions and where to use relation types safely and where developer scrutiny is required to prevent undefined behavior.





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.