2016-11-23 8 views
-1
#include<iostream> 
class Test { 
    static void fun() {} 
    void fun() {} // compiler error 
}; 

int main() 
{ 
    getchar(); 
    return 0; 
} 

출력 : 표준이 직접 금지로왜 C++에서 클래스의 정적 멤버를 오버로드 할 수 없습니까?

|4|error: ‘void Test::fun()’ cannot be overloaded|

+2

는 그래서, C 태그 ...이 기능을 자신의 –

+0

오른쪽 단추로 C++ 컴파일러를 제거하기 시작합니다. 우리는 대안이라고 부를 수 있습니다. –

답변

0

그것은 불가능합니다. 13.1 § C++14 표준 문서, 장을 인용

, "Overloadable 선언"

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