#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
class A
{
public:
A(char *s)
{
ptr=new char[strlen(s)+1];
strcpy(ptr,s);
}
~A()
{
delete ptr;
}
void print()
{
cout<<ptr<<endl;
}
A &operator=(const A& a)
{
if(this==&a)
return *this;
delete ptr;
ptr=new char[strlen(a.ptr)+1];
strcpy(ptr,a.ptr);
return *this;
}
private:
char *ptr;
};
void main()
{
A a("hello");
a.print();
A b(" ");
b=a;
b.print();
a.print();
}