用new运算符动态的分配内存,用delete运算符释放这些内存
1、以int*为例:
1.1、动态创建
int *channelLen;
channelLen = new int[3];
1.2、动态释放
delete []channelLen;
channelLen = NULL;
2、以float**为例:
2.1、动态创建:
float** Info = NULL;
Info = new float*[10];
for(int i=0;i<10;i++)
{
Info[i]=new float[300];
memset(Info[i],0,300*sizeof(float));
}
2.2、动态释放
for(int i=0; i<10; i++)
{
delete []Info[i];
Info[i] = NULL;
}
delete []Info;
Info = NULL;