Changes between Version 9 and Version 10 of CodingGuidelines


Ignore:
Timestamp:
Mar 29, 2012, 10:33:39 AM (13 years ago)
Author:
FrederikHeber
Comment:

added section on forward declarations

Legend:

Unmodified
Added
Removed
Modified
  • CodingGuidelines

    v9 v10  
    120120
    121121''Note:'' If a function is ''const in nature'' but modifies a very specific variable (specific to the function but needs to be contained in the class scope, e.g. a counter how often the function has been called), make it __mutable___.
     122
     123=== Use forward declarations === #code-good-bad-limits-forward-declarations
     124
     125Whenever possible __use forward declarations__ in header files. They are ''vital in reducing compilation times''. Remember that the preprocessor first compiles every include into the file subsequently served to the compiler. The larger this file becomes, the longer compilation takes.
     126
     127If a function defined in a header file just has the parameter as a reference or as pointer, don't add the include but only the forward declaration in the header file.
     128{{{
     129// some header file
     130
     131class MightyClass;
     132
     133class SmallClass {
     134  ...
     135  void foo(MightyClass &_m);
     136  ...
     137};