Next: High Integrity CPP Rule 8.4.7  Up: 8.4 Object Declarations and Definitions  Previous: High Integrity CPP Rule 8.4.5  Contents

High Integrity CPP Guideline 8.4.6   Use class types or typedefs to indicate scalar quantities.

Justification

Using class types to represent scalar quantities exploits compiler enforcement of type safety. If this is not possible typedefs should be used to aid readability of code for manual checking.

   
   #include "class_time_stamp.h";
   
   ClassTimeStamp start_time; // prefer (compiler type checking)
   
   long start_time;           // avoid
   
   typedef long TimeStamp;
   TimeStamp start_time;      // prefer
Reference

Industrial Strength C++ 15.12;


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