f*****y 发帖数: 1997 | 1 【 以下文字转载自 Programming 讨论区 】
发信人: fireicy (Light be with you.), 信区: Programming
标 题: 新手问一个多维数组传递给函数的问题
发信站: BBS 未名空间站 (Wed Dec 5 22:17:50 2012, 美东)
请大家看看我的new和delete用的对么? 传给函数的时候,是传指针还是数组名呢?
void main()
{
double **** g;
g = new double *** [m_ydimension];
for(i=0; i< m_ydimension; i++)
{
g[i] = new double ** [m_xdimension];
for (j=0; j< m_xdimension; j++)
{
g[i][j]= new double * [m_zdimension];
for (k=0; k
{
g[i][j][k] = new double [19];
for (l=0; l<19; l++)
{
g[i][j][k][l]=0.0;
}
}
}
}
ini_pop(double **** g, (int) m_ydimension, (int) m_xdimension, (int) m_
zdimension);
for (i=0;i
{
for (j=0;j
{
for (k=0; k
{
delete [] g[i][j][k];
}
delete [] g[i][j];
}
delete [] g[i];
}
delete [] g;
} |
|