If a member function does not alter any data in the class, then we may declare it as a const member function as follows:
void func(int , int) const;
float sum(float , float) const;
The qualifier const is appended to the function prototypes (in both declaration and definition). The compiler will generate an error message if such functions try to alter the data values of the data members of that class.
void func(int , int) const;
float sum(float , float) const;
The qualifier const is appended to the function prototypes (in both declaration and definition). The compiler will generate an error message if such functions try to alter the data values of the data members of that class.
No comments:
Post a Comment