1个回答
2016-01-05
展开全部
#include <vector>
using namespace std;
class CDemo{
public:
CDemo():str(NULL){}
~CDemo(){if(str) delete [] str;}
char *str;
};
int main()
{
CDemo d1;
d1.str = new char[32];
strcpy(d1.str, "trend micro");
vector <CDemo> *a1 = new vector <CDemo>();
a1 -> push_back(d1);
delete a1;
return 0;
}
using namespace std;
class CDemo{
public:
CDemo():str(NULL){}
~CDemo(){if(str) delete [] str;}
char *str;
};
int main()
{
CDemo d1;
d1.str = new char[32];
strcpy(d1.str, "trend micro");
vector <CDemo> *a1 = new vector <CDemo>();
a1 -> push_back(d1);
delete a1;
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询