标签:class 二维数组 ++ pre log 动态 code amp scanf
//在c++中通过构造来实现类对象的创建,通过析构来实现类对象的死亡 CMyClass mc(1);//类对象的创建 CMyClass *pmc = new CMyClass(2); //动态类对象的创建 delete pmc;//动态类对象的释放
int row, col; scanf("%d%d", &row, &col); //动态二维数组 int **p = new int *[row]; for (int i = 0; i < row; i++) *(p + i) = new int[col]; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { *(*(p + i) + j) = i*col + j + 1; //随便赋的值 } } for (int i = 0; i < row; ++i) { delete[] * (p + i);//删除底层指针 } delete[] p; //删除上层指针
标签:class 二维数组 ++ pre log 动态 code amp scanf
原文地址:http://www.cnblogs.com/ming-michelle/p/7617790.html