【C++】 动态二维数组 new 指向指针的指针

长时间不用c++了,把指针的用法给忘了,今天又用到了,到网上查了下,复习一下。

Code
#include <iostream>

usingnamespace std;

int main()
{
int row=4,col=5; //生成row行col列的2维动态数组
int**a=newint*[row];
int i,j;
for (i=0;i<row;i++)
{
a[i]
=newint[col];
}
for (i=0;i<row;i++)
{
for (j=0;j<col;j++)
{
a[i][j]
=i+j;
cout
<<a[i][j]<<"";
}
cout
<<endl;
}
return0;
}
posted @ 2008-10-13 14:35  gshine  阅读(7755)  评论(3编辑  收藏  举报