SFML community forums
Help => Window => Topic started by: treiguts on June 30, 2011, 12:41:00 pm
-
class a
{
sf::Window* m_Window; // class a member
a()
{
m_Window = new sf::Window; // I make new window object
m_Window.Create(...); // and creating window
}
error: request for member 'Create' in System*)this)->System::m_Window', which is of non-class type 'sf::Window*'|
Why can't I work with pointers? When I divide project in multiple classes, I can't pass Window to them and read pressed keys. m_Window.GetInput().IsKeyDown( sf::Key::Left )
-
Why can't I work with pointers?
Why should you? Pointers are not necessary in your case. They just make the situation more complicated.
class a
{
sf::Window m_Window;
// Use the constructor initializer list
a() : m_Window(sf::VideoMode(800, 600), "Title")
{
}
};
By the way, access to a member through a pointer requires the -> and not the . operator.
-
You should never use pointers unless it's absolutely necessary. 99% of the time, including this time, it isn't.