【发布时间】:2013-01-29 05:52:24
【问题描述】:
我正在使用 2D 数组在 Vs2010 c++ 中工作。 我从一维指针开始,使用 [] 操作如下:
class CMatrix
{
void clear();
public:
int nRows;
int nCols;
short * MyMat;
CMatrix();
CMatrix(int r,int c);
~CMatrix(void);
void SetMatrix(int r,int c);
short * operator[] (const int row)
{
return MyMat + (row*nCols);
}
};
我不介意更改为 2D 指针。
但是我的问题在于调试。因为我使用的是指针,所以看不到数组内容。
还有其他选择吗?
我不喜欢使用矢量。
【问题讨论】:
-
这是一个二维数组stackoverflow.com/a/13937325/942596。