#include<iostream>
class Test {
static void fun() {}
void fun() {} // compiler error
};
int main()
{
getchar();
return 0;
}
Output:
|4|error: ‘void Test::fun()’ cannot be overloaded|
#include<iostream>
class Test {
static void fun() {}
void fun() {} // compiler error
};
int main()
{
getchar();
return 0;
}
Output:
|4|error: ‘void Test::fun()’ cannot be overloaded|
It is not possible as the standard forbids it directly.
Quoting the C++14
standard document, chapter § 13.1, "Overloadable declarations"
Certain function declarations cannot be overloaded
Function declarations that differ only in the return type cannot be overloaded.
Member function declarations with the same name and the same parameter types cannot be overloaded if any of them is a
static
member function declaration. [....]