new 二维数组
在堆上声明一个数组 int main( ) { #if 0// 方式一: int** pArr = NULL; pArr = new int*[4]; for(int i = 0; i < 4; i++){ pArr[i] = new int[8]; } for(int i = 0; i < 4; ++i){ for(int j = 0; j < 8; ++j){ pArr[i][j] = i * j; } } for(int i = 0; i < 4; ++i){ for(int j = 0; j < 8; ++j){ if(j == 0) cout << endl; cout << pArr[i][j] << '\t'; } } // 删除 for(int i = 0; i < 4; ++i){ delete [] pArr[i]; } delete [] pArr; #endif // 方式二: cout << sizeof(int[5]) << endl; // 初始化 int(*pArr)[8] = new int[4][8]; memset(pArr, 0, sizeof(int[4][8])); // 或者 // int(*pArr)[8] = new int[4][8]{{0}}; cout << sizeof(int[4][8]) << endl; for(int i = 0; i < 4; ++i){ for(int j = 0; j < 8; ++j){ pArr[i][j] = i * j; } } for(int i = 0; i < 4; ++i){ for(int j = 0; j < 8; ++j){ cout << pArr[i][j] << '\t'; } cout << endl; } cout << endl; delete[] pArr; // 取地址 int arr[3][4]{{0}}; int(*p)[3][4] = &arr; cout << arr[2][3] << endl; cout << *p[2][3] << endl; return 0; } 输出:...