SUMMARY
  • If we have declared a pointer to constant, the compiler does not allow us to change that quantity by dereferencing the pointer.
  • A constant pointer means a pointer which cannot be modified after it is declared.
  • If we define a constant pointer to constant then we can neither modify that pointer nor modify the quantity it points.
  • Constant data member – It is possible to declare a data member of a class as constant. Such a member has to be initialized with a special syntax. For not initializing such a member, you get warning in TurboC++. It is an error with g++ compiler.
  • Constant method – It is possible to declare a method of a class as constant. The keyword const is applied after method name e.g. int print() const; Such methods are forbidden ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.