分配:
double **a=new double *[2*numPoints];
for(int i = 0; i <2*numPoints;i++)
a[i] = new double[8];
double *b =new double[2*numPoints];
释放:
for(int i = 0; i<2*numPoints;i++)
{
delete [8]a[i];
a[i]=NULL;
}
delete [2*numPoints]a;
delete []b;
a=NULL;
b=NULL;
如下:
float* fInit1DPointer(int num)
{
register int i;
float* p = new float[num];
for(i=0; i<num; i++)
{
p[i]=0.0f;
}
return(p);
}
void Free_f1DPointer(float *p)
{
delete [] p;
}
float** fInit2DPointer(int row,int col)
{
register int i,j;
float* arr = new float[row*col];
float** p = new float*[row];
for(i=0; i<row; i++)
{
p[i] = arr + i*col;
for(j=0; j<col; j++)
{
p[i][j]=(float)0.0;
}
}
return(p);
}
void Free_f2DPointer(float **p)
{
delete [] *p;
delete [] p;
}