I have seen a lot of examples where const is used instead of only declaring a constant variable.....so how does the const keyword function there.
For example:
1 2
virtualconstchar* what() const
{}
also:
void print(constint n) {}
what happens in the above codes if const is not used and what is the effect produced due to the usage of const keyword?
In case of a function, const can only be used with a member function. In that case the const prevents the modification of the member variables of this object.