STL stack 的有关问题
STL stack 的问题
我想一个维数组 入stack
std::stack<int[2]> s1;
int temp[2] = {0,0};
s1.push(temp);
用这样方法为什么不行;
报错是:
c:\program files\microsoft visual studio 8\vc\include\xmemory(53) : error C2075: “Target of operator new()”: 数组初始化需要大括号
------解决方案--------------------
容器内元素必须可以被赋值。数组不能被赋值,因此无法成为容器内的元素类型。
------解决方案--------------------
因为数组不能拷贝赋值所以容器里面是不可能存放数组的
------解决方案--------------------
------解决方案--------------------
我想一个维数组 入stack
std::stack<int[2]> s1;
int temp[2] = {0,0};
s1.push(temp);
用这样方法为什么不行;
报错是:
c:\program files\microsoft visual studio 8\vc\include\xmemory(53) : error C2075: “Target of operator new()”: 数组初始化需要大括号
------解决方案--------------------
容器内元素必须可以被赋值。数组不能被赋值,因此无法成为容器内的元素类型。
------解决方案--------------------
因为数组不能拷贝赋值所以容器里面是不可能存放数组的
------解决方案--------------------
------解决方案--------------------