0
#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|

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
Mock_Arch
  • 31
  • 4

1 Answers1

1

It is not possible as the standard forbids it directly.

Quoting the C++14 standard document, chapter § 13.1, "Overloadable declarations"

  1. 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. [....]

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261