请问这个程序中c_1,c_3的析构函数为什么没有调用呀
#include <iostream>
using namespace std;
class CCountry{
private:
char *m_name;
double m_area;
public:
CCountry();
CCountry(char*,double);
//析构函数
~CCountry();
CCountry(const CCountry &obj);
void Print();
int CompareArea(CCountry);
};
CCountry::CCountry()
{
cout<<"无参构造函数"<<endl;
}
CCountry::CCountry(char* name,double area)
{ //char*不能直接转string
string str=name;
cout<<str<<"的含参构造函数"<<endl;
m_area=area;
m_name=name;
}
CCountry::~CCountry()
{
string str=m_name;
cout<<str<<"的析构函数"<<endl;
}
CCountry::CCountry(const CCountry &obj)
{
m_area=obj.m_area;
m_name=obj.m_name;
string str=m_name;
cout<<str<<"的拷贝构造函数"<<endl;
}
void CCountry::Print()
{
cout<<m_name<<" "<<m_area<<endl;
}
//该对象比传入对象大,返回1
int CCountry::CompareArea(CCountry c)
{
if(m_area>c.m_area)
{return 1;}
if(m_area<c.m_area)
{return 0;}
if(m_area==c.m_area)
{return 2;}
return -1;
}
int main()
{ cout<<"dsqw"<<endl;
CCountry c_1((char*)"coutry1",20.0);
CCountry *c_2 =new CCountry((char*)"country2",30);
CCountry c_3(c_1);
CCountry c_4((char*)"country4",40);
c_1.Print();
c_2 ->Print();
c_3.Print();
c_4.Print();
cout<<c_1.CompareArea(c_4)<<endl;
delete(c_2);
system("pause");
}