A function becomes const when const keyword is used in function’s declaration. The idea of const functions is not allow them to modify the object on which they are called. It is recommended practice to make as many functions const as possible so that accidental changes to objects are avoided.
Following is a simple example of const function.
When a function is declared as const, it can be called on any type of object. Non-const functions can only be called by non-const objects.
For example the following program has compiler errors.
passing 'const Test' as 'this' argument of 'int Test::getValue()' discards qualifiers
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
This article is attributed to GeeksforGeeks.org