对象数组的向量- push_back()
Vector of Arrays of Objects - push_back()
作为线程的名称,我有添加元素到我的向量的问题…非常相似的构造可以完美地工作(对象的向量数组)
Game.h
class Game: parent, stan
{
public:
(...)
struct lista_boardow
{
stan tabliczka[8][8];
};
std::vector<lista_boardow> _lista_boardow;
(...)
static int AiMove(std::vector<lista_boardow>& vect, stan _b[][8]);
(...)
第二个:
Game.cpp
(...)
int Game::AiMove(std::vector<lista_boardow>& vect, stan tym_board[][8])
{
stan tabi[8][8];
(...)
vect.push_back(tabi); // ?????
}
(...)
错误:
error C2664: 'void std::vector<_Ty>::push_back(_Ty &&)' : cannot convert parameter 1 from 'stan [8][8]' to 'Game::lista_boardow &&'
任何想法?
你有什么问题?
#include <iostream>
#include <vector>
using namespace std;
struct elem {
int value;
elem(int value) : value(value) {}
};
struct nih_array {
elem data[2][2];
};
int main() {
vector<nih_array> v;
v.push_back({1, 2, 3, 4});
cout << v[0].data[1][0].value << endl; // "3", no problem here
}
活版本。
相关文章:
- 推导 std::vector::back() 的返回类型
- vector.back() 和 vector[vector.size() - 1] 之间的区别?
- vector.push_back(vector.back()+1) 是未定义的行为吗?
- C++自己的对象堆栈.在 push() 上复制了什么?
- C++ push() 和 pop() 方法使用指针的动态 LinkedList 的问题
- 如何像在javascript中一样"push" c ++映射
- 线路抑制状态错误 C4703 可能未初始化的局部指针变量"back"已使用
- std::vector using back(), pop_back(), push_back(), 得到'double free or corruption'错误
- vector.back()和vector.end()有什么区别
- 列表大小为 1,但 front() 和 back() 不相等
- 返回C++中没有 back() 方法的容器的最后一个元素?
- 在非空 std::list 上使用 std::list.back<int>() 时"Segmentation Fault"
- 模板堆栈类的复制构造函数中的 pop() 和 push() 不起作用
- 我们可以使用Back() - 值索引在其上执行向量插入
- 当我运行以下代码添加str.front() str.back时,它给了我200个,但为什么
- push(ing)back在循环中对象指针
- 在 C++ 中将元素添加到空向量:为什么 push.back 有效而 [] 无效
- 我似乎无法让 v.push.back() 处理字符串
- String::push_back() does not push back
- 向量resize(), push.back(), reserve()方法