动态分配内存
2017-02-21 本文已影响13人
lusoer
动态分配内存初始化的方式
int *p=new int(6);//对动态分配的内存赋初值
struct where {double x; double y; double z;};
where * one = new where {2.5, 5.3, 7.2}; // C++11
int * ar = new int [4] {2,4,6,7}; //c++1标准
初始化列表(list initialization)对于数组、类、结构体都是试用的。