Sunday, October 24, 2010

Const

The following function declaration:
   void func(MyClass & const myClassObject);
is illegal, because of the 'const'.

The 'const' in the following declaration:
   void func(MyClass * const myClassObject);
is useless, because the pointer is passed by value, so the 'const' does not add anything.

Reference: Exceptional C++ by Herb Sutter. Addison-Wesley, 1999, p. 181.

No comments:

Post a Comment