-1
#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
  • 130,437
  • 16
  • 177
  • 247
Mock_Arch
  • 21
  • 4

1 Answers1

0

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
  • 130,437
  • 16
  • 177
  • 247