[Univ of Cambridge] [Dept of Engineering]
next up previous contents
Next: Makefiles Up: Program Development Previous: Program Development

Style

It helps if you decide upon a uniform style for writing code. It's common to suggest that for all except the most trivial classes it's wise to define And then there's the "the rule of three" - if you write any one of a copy constructor, copy assignment operator or destructor, then you will almost certainly need to write all three for your class to function properly.

Stanley Lippman in Dr.Dobb's Journal, October 99, (p.40) noted that unnecessary definition of these functions is likely in practise to make the code bigger and/or slower - he got a 40% speed improvement by removing all 3 from a piece of code, the compiler's default alternatives being more efficient.

When deriving classes


next up previous contents
Next: Makefiles Up: Program Development Previous: Program Development
Tim Love
2001-07-05