#Previous question #Index of C++ Questions #Next question

If a member function of a class does not alter any data in the class, then this member function may be declared as a constant function using the keyword const.

Consider the following declarations:

int max(int,int) const;
void prn(void) const;

Once a function is declared as const, it cannot alter the data values of the class. The complier will generate an error message if such functions try to change the data value.

You have viewed 1 page out of 62. Your C++ learning is 0.00% complete. Login to check your learning progress.

Most popular topics (must visit)

Useful links for students