Search code examples
c++sfml

Getting an error using the WindowSetup class variable


here is WindowSetup.h

class WindowSetup
{

public:

    WindowSetup();
    WindowSetup(const string& l_title ,Vector2u& l_size);
   ~WindowSetup();

}

Game.H

class Game
{
    Game();
   ~Game();

    WindowSetup m_window;
}

and the error is in Game.cpp

Game::Game():m_window("zzzzzz",Vector2u(800,600))
{


}

error :Severity Code Description Project File Line Suppression State Error (active) E0289 no instance of constructor WindowSetup::WindowSetup matches the argument list

The argument list matches but still it gives error.


Solution

  • You have to add const to the arguments of the constructor:

    WindowSetup(const string& l_title, const Vector2u& l_size);
    

    Vector2u(800,600) is an r-value. You can't create a non-const reference of an r-value.