我想用向量来创建2D数组。但是,当我这样做的时候,我得到了seg错误。谁能解释一下我做错了什么,以及这个问题的可能解决方案。
我公开了所有的东西,因为我现在不想和getter和setter打交道。我想弄清楚二维数组的概念。
#include <iostream>
#include <vector>
using namespace std;
class point
{
public:
point():x(0),y(0){}
~point(){}
point(float xx,float yy):x(xx),y(yy){}
float x,y;
};
int main()
{
vector<vector<point> > a; // 2D array
point p(2,3);
a[0][0] = p; // error here
return 0;
}
https://stackoverflow.com/questions/1833127
复制相似问题