[英]Set my window in a class c++
我不知道為什么,但是在課堂上創建窗口時出現錯誤。
錯誤是:
game.cpp(11): error C2064: term does not evaluate to a function taking 2 arguments
我不理解這個的原因,負責人是在類的構造函數中:
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
}
在我的標題window.h
中私下設置為:
private:
std::map<string, string> settings;
std::map<string, string> theme;
sf::RenderWindow window;
我的main.cpp
設置如下:
Application game(setting,style);
可能是什么原因造成的?
使用成員初始值設定項初始化您的成員:
Application::Application(std::map<string,string>& s, std::map<string, string>& t)
:settings(s),
theme(t),
window(sf::VideoMode(800, 600), "Test")
{
}
它被稱為成員初始化列表。成員初始化列表由逗號分隔的初始化列表組成,前面有冒號。 它位於參數列表的右括號之后和函數體的左括號之前。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.