2010-05-29 3 views
0

내 응용 프로그램의 입력 시스템에 SFML을 사용하고 있습니다.입력 시스템 참조 문제

size_t WindowHandle; 
WindowHandle = ...; // Here I get the handler 

sf::Window InputWindow(WindowHandle); 
const sf::Input *InputHandle = &InputWindow.GetInput(); // [x] Error 

마지막 줄에는 입력 시스템에 대한 참조가 필요합니다.

const Input & sf::Window::GetInput() const 

문제는 다음과 같습니다 :

>invalid conversion from ‘const sf::Input*’ to ‘sf::Input*’ 

어떤 문제가 여기에

documentation에서 getInput에의 선언입니까?

답변

1

참조가 아닌 포인터가 필요한 특별한 이유가 있습니까? 하지 않으면, 당신은이를 시도 할 수 :

const sf::Input & InputHandle = InputWindow.GetInput(); 

이 당신에게 당신의 입력 핸들에 대한 참조를 반환합니다.

, BTW이 나를 위해 일한 :

const int& test(int& i) 
{ 
    return i; 
} 

int main() 
{ 
    int i = 4; 

    const int* j = &test(i); 

    cout << *j << endl; 
    return 0; 
} 

출력 : 컴파일러가 당신이 참조를 가리 키도록하지 않는 이유

4 모르겠어요.