#include <iostream>
using namespace std; void main()
{
//用new创建一个二维数组,有两种方法,是等价的
//一:
int (*p)[] = new int[][];
//二:
int **p = new int* [];
for(int i=;i <;i++)
p[i] = new int[]; //指针数组的创建,也有两种方法
//一:
char **pa = new char* [];
for (int i=;i <;i++)
{
pa[i] = new char[]; //为每个指针都分配8个char元素空间。
}
//二:
char *pa[];//可以不用new创建
for (int i=;i <;i++)
{
pa[i] = new char[]; //为每个指针都分配8个char元素空间。
} //delete二维数组
//for一:
delete []p;
//for二:
for(int i=; i <; ++i)
delete []p[i];
delete []p; //delete指针数组
//for一:
for(int i=; i <; ++i)
delete []pa[i];
delete []pa;
//for二:
for(int i=; i <; ++i)
delete []pa[i];
}
from here