Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/139.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++ sf::RenderWIndows的向量_C++_C++14_Sfml - Fatal编程技术网

C++ sf::RenderWIndows的向量

C++ sf::RenderWIndows的向量,c++,c++14,sfml,C++,C++14,Sfml,我有一个需要打开多个sfml窗口的程序,我正在尝试使用一个函数将窗口放回阵列。我用unique_ptr制作了向量,但是当我使用emplace_返回时,我得到了这个错误 Error C2664 'sf::RenderWindow::RenderWindow(const sf::RenderWindow &)': cannot convert argument 1 from '_Ty' to 'sf::WindowHandle' C:\Program Files (x86)\Microso

我有一个需要打开多个sfml窗口的程序,我正在尝试使用一个函数将窗口放回阵列。我用unique_ptr制作了向量,但是当我使用emplace_返回时,我得到了这个错误

Error C2664 'sf::RenderWindow::RenderWindow(const sf::RenderWindow &)': cannot convert argument 1 from '_Ty' to 'sf::WindowHandle'  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\memory  2064    
产生错误的最小代码:

void MakeKey::DrawKey(字符串输入)
{
unique_ptr window=make_unique(新sf::RenderWindow);
MakeKey::NewKey;
如果(输入=“A”)
Key.Img.loadFromFile(“Assets/Images/A.png”);
否则如果(输入=“D”)
Key.Img.loadFromFile(“Assets/Images/D.png”);
//ect
窗口->创建(sf::VideoMode(Key.Img.getSize().x,Key.Img.getSize().y,32),“Key”,sf::Style::None);
独特的_ptrwindowptr;
WindowArray.emplace_back(移动(windowPtr));
Key.Tex.loadFromImage(Key.Img);
Key.Sprite.setTexture(Key.Tex);
键盘阵列。向后放置(移动(键));
WindowArray.emplace_back(移动(窗口));
库特
这是
make_unqiue
的替代方案,但出于简单和高效的考虑,通常首选
make_unique

也不要忘记,您可以通过使用auto进一步简化

auto window = make_unique<sf::RenderWindow>();
auto window=make_unique();

好的,谢谢。对不起,这可能是我应该自己解决的问题。
unique_ptr <sf::RenderWindow> window = make_unique<sf::RenderWindow>();
unique_ptr <sf::RenderWindow> window(new sf::RenderWindow>());
auto window = make_unique<sf::RenderWindow>();