typedef std::string AddressLines[4]定义了一个string数组,大小为4

int main()
{
    typedef std::string AddressLines[4];

    std::string *pal = new std::string[4];
    std::string *pal1 = new AddressLines;

    delete [] pal;
    delete [] pal1;

    return 0;
}

typedef std::string AddressLines[4]; 这样定义居然是代表AddressLines是一个string数组,4个string。

 

new std::string[4] 和 new AddressLines 是同一个意思,删除时必须用delete[]

 

posted @ 2015-01-06 02:30  YinaPan  阅读(467)  评论(3编辑  收藏  举报