Reputation: 8280
I don't know why but I'm getting an error when creating my window in a class.
The error is:
game.cpp(11): error C2064: term does not evaluate to a function taking 2 arguments
I'm not understanding the cause of this, the responsible is in the constructor for the class :
window.cpp
Application::Application(std::map<string,string>& s, std::map<string, string>& t){
settings = s;
theme = t;
window(sf::VideoMode(800, 600), "Test"); //error is here
}
In my header window.h
is set up in private as:
private:
std::map<string, string> settings;
std::map<string, string> theme;
sf::RenderWindow window;
My main.cpp
sets it up like so:
Application game(setting,style);
What could be the cause of this ?
Upvotes: 0
Views: 166
Reputation: 45410
Use member initializers to initialize your members :
Application::Application(std::map<string,string>& s, std::map<string, string>& t)
:settings(s),
theme(t),
window(sf::VideoMode(800, 600), "Test")
{
}
It’s called a member initializer list.The member initializer list consists of a comma-separated list of initializers preceded by a colon. It’s placed after the closing parenthesis of the argument list and before the opening bracket of the function body.
Upvotes: 2