[英]Set my window in a class c++
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: 在我的标题
window.h
中私下设置为:
private:
std::map<string, string> settings;
std::map<string, string> theme;
sf::RenderWindow window;
My main.cpp
sets it up like so: 我的
main.cpp
设置如下:
Application game(setting,style);
What could be the cause of this ? 可能是什么原因造成的?
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.
它位于参数列表的右括号之后和函数体的左括号之前。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.