skip to main | skip to sidebar

C++ Tutorials

const Member Function

If a member function does not alter any data in the class, then we may declare it as a const member function as fallows:

void mul(int ,int) const;
double get_balance() const;

The qualifier const is appended to the function prototype. The compiler will generate an error message if such functions try to alter the data values.

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

My Blog List

  • Ask about web
    How to set div beside each other ?
    14 years ago
  • C++ Tutorials
    Pointer to Members
    14 years ago
  • C Programming
    Masking
    14 years ago
  • ASP.NET Tutorials
    Difference between SGML, and XML
    14 years ago
  • Linux Tutorials
    Program for Palindrome
    15 years ago
  • Visual Basic Tutorials
    Code Editior Window
    15 years ago
  • Java Program
    Introduction of Java
    15 years ago

Blog Archive

  • ▼  2010 (35)
    • ▼  July (24)
      • Pointer to Members
      • const Member Function
      • A friend function possesses certain special charac...
      • Friendly Functions
      • Array of Objects
      • Static Member Functions
      • Static Data Members
      • Array within a Class
      • Private Member Functions
      • Nesting of Member Functions
      • Making an Outside Function Inline
      • Outside the Class Definition
      • Defining Member Functions
      • Specifying a Class
      • C Structure Revisited
      • Friend and Virtual Functions
      • Function Overloading
      • const Arguments
      • Default Arguments
      • Inline Functions
      • Return by Reference
      • Call by Reference
      • Function Prototyping
      • The Main Function
    • ►  May (11)