#include<iostream>
using namespace std;
class Test
{
public:
Test(int i,int j):m(i),n(j)
{
}
int Get()
{
return m;
}
int Get() const
{
return m+n;
}
private:
int m;
int n;
};
void main()
{
Test t1(3,4);
const Test t2(3,4);
cout<<t1.Get()<<endl;
cout<<t2.Get()<<endl;
}
上述输出为3,7;可见const可以让两个同名函数发生重载的。