非成员函数可以多次声明,而成员函数只能声明一次?这是正确的吗 ?我的例子似乎是肯定的。
但为什么 ?
class Base{
public:
int foo(int i);
//int foo(int i=10); //error C2535: 'void Base::foo(int)' : member function already defined or declared
};
//but it seems ok to declare it multiple times
int foo(int i);
int foo(int i=10);
int foo(int i)
{
return i;
}
int main (void)
{
int i = foo();//i is 10
}