Member function declarations with the same name and the name parameter-type-list cannot be overloaded if any of them is a static member function declaration. For example, following program fails in compilation.
#include<iostream>
class Test {
static void fun(int i) {}
void fun(int i) {}
};
int main()
{
Test t;
getchar();
return 0;
}
I don't understand why the following example can run:
#include<iostream>
class Test {
public:
static void fun(double i) {
std::cout << i << "\n";
}
void fun(int i) {
std::cout << i;
}
};
int main()
{
Test t;
t.fun(5.5);
t.fun(4);
return 0;
}