Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.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+中附加到它+;?_C++_Vector_Cout - Fatal编程技术网

C++ 如何创建元组向量并在C+中附加到它+;?

C++ 如何创建元组向量并在C+中附加到它+;?,c++,vector,cout,C++,Vector,Cout,我试图创建一个元组向量,我可以在整个代码中添加它。我是超级新到C++,所以我只是尝试一个玩具的例子,创建一个元组向量,并添加一个元素。我的代码如下所示: std::vector<std::tuple<int, int>> coords; coords.push_back(<std:tuple<4,4>>); cout << coords <<endl; 我很困惑,这是什么意思?如果我只是创建向量而不附加/打印,它就会编译。

我试图创建一个元组向量,我可以在整个代码中添加它。我是超级新到C++,所以我只是尝试一个玩具的例子,创建一个元组向量,并添加一个元素。我的代码如下所示:

std::vector<std::tuple<int, int>> coords;
coords.push_back(<std:tuple<4,4>>);
cout << coords <<endl;

我很困惑,这是什么意思?如果我只是创建向量而不附加/打印,它就会编译。为什么这些都失败了?

这是幻想语法:

coords.push_back(<std:tuple<4,4>>);

PS:
这既不是构造元组的方式,也不是打印向量内容的方式。这也不是感谢。我将我的
push_back
代码更改为您推荐的代码,并暂时删除了
cout
代码。我仍然收到错误
错误:未知类型名称“coords”
。我认为我有语法权利创建/命名我的向量为
coords
?@connor449错误
未知类型名称“coords”
来自您的帖子中未包含的代码。我只是根据你发布的代码回答的。请阅读,下次请确保您发布的代码是创建要修复的错误的代码
coords.push_back(<std:tuple<4,4>>);
coords.push_back(std::tuple<int,int>{4,4});
coords.emplace_back(4,4);