Monday, May 19, 2014

CONST

CONST

  • const correctness : C++ compiler's detection of many unexpected changes to objects and flags these violations with error messages at compile time. All tests for constness are done at compile time. 
  • const doesnot imply runtime overhead. Neither runtime space nor speed is degraded. 
  • The purpose of const is correctness, not optimization. The const helps the compiler find bugs, but it does not (normally) help the compiler generate more efficient code. 
  • const correctness is no more tedious than declaring the type of a variable. 
  • The compiler won't allow a const member function to change *this or to invoke a non-const member function for this object. 
  • const should not be used for formal parameter types that are passed by value.
it is inappropriate to use Fred* const in a formal parameter list. do not use Fred& const in any context 
  • The mutable keyword tells the compiler that const member functions are allowed to change the data member.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home