Next: 3.4 Object Oriented Design  Up: 3 Class  Previous: 3.2 Constructors and Destructors  Contents

3.3 Inheritance

3.3.1

High Integrity CPP Rule

Use public derivation only.

3.3.2

High Integrity CPP Rule

Write a 'virtual' destructor for base classes.

3.3.3

High Integrity CPP Rule

Avoid downcasting base class object pointers to derived class.

3.3.4

High Integrity CPP Rule

Avoid casting to a virtual base class as this is irreversible.

3.3.5

High Integrity CPP Rule

Override all overloads of a base class virtual function.

3.3.6

High Integrity CPP Rule

If a virtual function in a base class is not overridden in any derived class then make it non virtual.

3.3.7

High Integrity CPP Rule

Only define virtual functions in a base class if the behaviour will always be valid default behaviour for derived classes.

3.3.8

High Integrity CPP Rule

Declare a function pure virtual in the base class if each derived class has to provide specific behaviour.

3.3.9

High Integrity CPP Rule

If a virtual function is overridden in each derived class with the same implementation then make it a non virtual function in the base class.

3.3.10

High Integrity CPP Rule

Ensure that the return type of the virtual function being overridden is compatible.

3.3.11

High Integrity CPP Rule

Do not overload or hide inherited non-virtual functions.

3.3.12

High Integrity CPP Rule

When redeclaring and overriding functions use the same default parameter values as in other declarations.

3.3.13

High Integrity CPP Rule

Do not invoke virtual methods of the declared class in a constructor or destructor.

3.3.14

High Integrity CPP Rule

Declare the copy assignment operator protected in an abstract class.

3.3.15

High Integrity CPP Rule

Ensure base classes common to more than one derived class are virtual.

3.3.16

High Integrity CPP Rule

Explicitly declare polymorphic member functions virtual in a derived class.


HICPP VERSION 2.4  http://www.codingstandard.com   Copyright: © 2007 THE PROGRAMMING RESEARCH GROUP