Lecture overview -- Keyboard shortcut: 'u'  Previous page: Declarations as statements - declarations in conditions -- Keyboard shortcut: 'p'  Next page: The general notation of objects in C++ -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 2 - Page 9 : 42
Notes about C++
Basic facilities
Constants

The const qualifier can be used in several different contexts in C++

Constness is a fairly complicated matter in C++

  • The C++ Programming Language: Page 94 - 97
 

  • The basics

    • The const qualifier can be applied to objects, types, and member functions

    • Constant objects cannot be mutated

  • Pointers and const

    • Either a constant pointer or a pointer to something constant

      • this is a constant pointer

    • *const is declarator operator - constant pointer

      • Other declarator operators: *, [], and ()

  • References and const

    • By nature a reference is constant - once the reference is establised it cannot be changed

  • Member functions and const

    • A constant member function cannot modify the state of the object

y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/constants/const-ptr-1.ccExamles constants, pointers to constants, and constant pointers.