string数组在c++中如何析构啊?

来源:百度知道 编辑:UC知道 时间:2024/05/29 13:39:57
string *word_list = new string[10];
内容是 :one,two ,three,four,five,six,……ten.
析构要怎么做啊?直接析构不行……
难道要重载吗?重载的时候,说是:不知道void *的大小~求助大侠了

delete []word_list,delete new分配的内存会自动调用string类的析构函数

#include<stdio.h>
#include <string>
using namespace std;
void main()
{
string* str=new string[10];

if (str) //释放空间
{
delete[] str;
}
}

直接delete[] word_list