Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/144.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 从类返回渲染窗口_C++_Sfml - Fatal编程技术网

C++ 从类返回渲染窗口

C++ 从类返回渲染窗口,c++,sfml,C++,Sfml,我有点纠结于如何从类返回渲染窗口,不确定返回类型是否错误,语法是否错误,或者两者都有 My main.cpp有: Window Render(800, 600, "Test"); sf::RenderWindow window = Render.Init(); 我的课程是: Window::Window(int x, int y, std::string title){ ResoX = x; ResoY = y;

我有点纠结于如何从类返回渲染窗口,不确定返回类型是否错误,语法是否错误,或者两者都有

My main.cpp有:

Window Render(800, 600, "Test");
sf::RenderWindow window = Render.Init();
我的课程是:

        Window::Window(int x, int y, std::string title){
            ResoX = x;
            ResoY = y;
            Title = title;
        }

    sf::RenderWindow Window::Init(){
        return screen(sf::VideoMode(ResoX,ResoY,Title));
    }
类的标题:

class Window
{
    private:
        int ResoX, ResoY;            
        std::string Title;
        sf::RenderWindow screen;
    public:
    Window(int, int, std::string);

    sf::RenderWindow Init();
};
我的错误是:

错误C2665:'sf::VideoMode::VideoMode':3个重载都不能转换所有参数类型
可以是“sf::VideoMode::VideoMode(无符号整数、无符号整数、无符号整数)”
尝试匹配参数列表时“(int,int,std::string)

错误C2064:术语不计算为带1个参数的函数

有人知道我如何解决这个问题吗?

来自SFML文档(http://www.sfml-dev.org/documentation/1.6/classsf_1_1VideoMode.php#a9478572db06121f70260e6b9dc21704e

sf::VideoMode构造函数声明为:

sf::VideoMode::VideoMode(unsigned int   ModeWidth,
                         unsigned int   ModeHeight,
                         unsigned int   ModeBpp = 32 
                         )  
这意味着您不能将第三个参数作为字符串传递,您可以调用它:

return screen(sf::VideoMode(ResoX,ResoY));