About 15,900 results
Open links in new tab
  1. If a function should be able to be called on a const object, it should be designated as const.

  2. Use const references or call-by-value for input values Particularly for large (# bytes) values, use references (no copying)

  3. The “const” suffix for a read-only method like getMonth can only appear inside a method declared as a member of a class. It means “read only property” of the object the class defines.

  4. Note that constructors should not be marked as const. This is because const objects should initialize their member variables, and a const constructor would not be able to do so.

  5. When you put "const" in front of a parameter, it means that it cannot be modified in the function. (In other words, you'll get a compile-time error if you try to assign to it.)

  6. Although the const qualifier appears in p’s declaration, it applies only to what p points to, not to p itself. If p were declared as “constpointer to ...” then p would have a const-qualified type.

  7. References allow a function to change the value of the argument, which is sometimes useful. Otherwise, const references can be used to guarantee the function won't change the argument. Because a copy …