7.1. What Is Class Design?

Here are several questions to ask yourself and a list of topics to consider when designing classes.

  • What behaviors do I need?

  • Do I need to overload operators?

  • Are the compiler defaults correct?

  • What user-defined conversions do I need?

Good class design requires an understanding of how applications use objects. This knowledge helps you design object behaviors and determine what parts of your objects you should encapsulate. Compiler defaults are important because assignment and copy initialization may not work properly if you do not provide their implementations. User-defined conversions are also important since constructors and cast operators help applications work with objects in consistent ways.

Get Navigating C++ and Object-Oriented Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.