0
\$\begingroup\$

I have been following the "SFML Game Development By Example" and on chapter 2, the book was showing the example game design of a Snake game. However he didn't write the code of some header classes and didn't mention whether they should exist. I tried writing some of them but encountered an error:

sf::RenderWindow* Window::GetRenderWindow(return &m_window;)

Error: declaration is incompatible with sf::RenderWindow *Window::GetRenderWindow()

In my Window class:

class Window{

public:
    ...
    sf::RenderWindow* GetRenderWindow();
    ...
private:
    ...
    sf::RenderWindow m_window;
    ...
}

I think it is probably because of the function declaration.

\$\endgroup\$
0
\$\begingroup\$

sorry for the silly question. It is time to sleep I guess. Here is the corrected version:

sf::RenderWindow* Window::GetRenderWindow() {
    return &m_window;
}
\$\endgroup\$
  • \$\begingroup\$ Don't forget to come back and mark this answer as accepted when it's possible :) \$\endgroup\$ – Vaillancourt Feb 27 '18 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.