#### 6.浅拷贝与深拷贝

/**************************************
//Des：C++教程配套程序
//Author:Huang
//Date:2017/8/26
**************************************/
#include<iostream>
#include<Cstring>
using namespace std;
#define PI 3.1415
class Circle
{
private:
double R;
char *str;
public:
Circle(double R,char *str);
~Circle();
double area();
double girth();
};
Circle::~Circle()
{
delete []str;
}
Circle::Circle(double R,char *str)
{
cout<<"Constructor"<<endl;
this->R = R;
this->str = new char[strlen(str)+1];
strcpy(this->str,str);
cout<<this->R<<" "<<this->str<<endl;
}

double Circle::area()
{
return PI*R*R;
}
double Circle::girth()
{

return 2*PI*R;
}
int main()
{

Circle A(5,"NO.1 Old class");
Circle B(A);
return 0;
}

This->str = str;

#include<iostream>
#include<Cstring>
using namespace std;
#define PI 3.1415
class Circle
{
private:
double R;
char *str;
public:
Circle(double R,char *str);
Circle(Circle &A);
~Circle();
double area();
double girth();
};

Circle::~Circle()
{
delete []str;
cout<<"Call Destructor"<<endl;
}
Circle::Circle(Circle &A)
{
cout<<"Copy Constructor"<<endl;
this->R = A.R;
this->str = new char[strlen(A.str)+1];
strcpy(this->str,A.str);
}
Circle::Circle(double R,char *str)
{
cout<<"Constructor"<<endl;
this->R = R;
this->str = new char[strlen(str)+1];
strcpy(this->str,str);
}

double Circle::area()
{
return PI*R*R;
}
double Circle::girth()
{
return 2*PI*R;
}
int main()
{

Circle A(5,"NO.1 Old class");
Circle B(A);
return 0;
}