How I declare my class and why -- Howard Hinnant

Save to:
Instapaper Pocket Readability

An experience-based opinion piece from one of the masters of C++:

How I declare my classes and why

by Howard Hinnant

Howard is the lead designer and author of move semantics, and a longtime C++ committee member where he has served as chair of the Library Working Group and is a current member and recent chair of the Direction Group.

From the article:

When I'm reading a class declaration, the very first things I want to know are:

  • What resources does this class own?
  • Can the class be default constructed?
  • Can the class be copied or moved?
  • How can the class be constructed (other than by default, copy or move)?
  • What else can one do with the class?

Note that this is an ordered list...

Add a Comment

Comments are closed.

Comments (1)

0 0

Andy said on Feb 28, 2020 07:12 AM:

Funny how it is so easy to know and talk about theory and good practices and yet don't follow the rules when writing code.
It seems that you forgot about point 4 and 5 from your list while implementing <chrono>. Others seem to have similar feelings:

https://www.fluentcpp.com/2019/12/10/dont-make-your-interfaces-deceptively-simple/