动态分配内存

作者: lusoer | 来源:发表于2017-02-21 23:20 被阅读13次

    动态分配内存初始化的方式

    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)对于数组、类、结构体都是试用的。

    相关文章

      网友评论

        本文标题:动态分配内存

        本文链接:https://www.haomeiwen.com/subject/mflpwttx.html