Tuesday, November 23, 2010

Const and Extern Specifiers

All of the following statements compile:

extern int const i1 = 42;
         int const i2 = 42;
  const  int       i3 = 42;
  const extern int i4 = 42;
  const extern int i4 = 42;


Some people such as authors David Vandevoorde and Nicolai M. Josuttis prefer the int const' versions of the above declarations.

References:
C++ Templates by David Vandevoorde. Addison-Wesley, 2003.
http://codecraft.pool-room.com/Cpp/const-correctness-3.html

No comments:

Post a Comment