C++ Const Member Functions
A constant (const) member function can be declared by using const keyword, it is used when we want a function that should not be used to change the value of the data members i.e. any type of modification is not allowed with the constant member function.
Example:
Here, we have a class named "Numbers" with two private data members a and b and 4 member functions two are used as setter functions to set the value of a and b and 2 are constant members functions which are using as getter functions to get the value of a and b.
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer