See web reference links at the bottom for more information
| You Can Do It!: A Beginners Introduction to Computer Programming |
|---|
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.
const used after a data type in pseudocode1):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.
| C++ Primer Plus (5th Edition, 2nd printing) |
|---|
// The const keyword is in front of the data type and variable const int MONTHS = 12;
: 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.
| You Can Do It!: A Beginners Introduction to Computer Programming |
|---|
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.