In C++, a function\'s signature depends partly on whether or not it\'s const. This means that a class can have two member functions with identical signatures except that on
#include
using namespace std;
class base
{
public:
void fun() const
{
cout<<"have fun";
}
void fun()
{
cout<<"non const";
}
};
int main()
{
base b1;
b1.fun(); //does not give error
return 0;
}
Here compiler won't give any error, because in case of const
functions compiler converts this
pointer to const this*
. this third argument separates these two functions.