Table of Contents

const keyword

See web reference links at the bottom for more information

Does the const keyword precede or follow the data type?

:!: NOTE: Francis Glassborow uses a form of initialization that he refers to as a function-style initialization, whereas I (and maybe you) are used to the assignment style for variables.

nothing climb_stairs(staircase const & stairs, person & me){
      for(int i(0); i != stairs.number_of_steps(); ++i){
                  me.step_up_one_step();
      }
}
// const is after the data type
string const endinput("END");
While there is some allowance for varying the position of ''const'' in a declaration, 
it must not come after the symbol that qualifies a type as a reference type.
// The const keyword is in front of the data type and variable
const int MONTHS = 12;

Does the const keyword precede or follow function declarations?

FIXME: Needs to be verified

It would seem that this is of use for pointers and references (not sure) as returning anything else would be a pass by value and const would not be needed.

To answer the question, it is a prefix for the return value.

Does the const keyword precede or follow member function declarations?

const objects must have const member functions. The syntax for const member functions is to place the const keyword after the function parenthesis. This tells the compiler that any object passed to the function will not be changed.

Web References

1) Fixed a typo here that is present in my edition of the book