#include <iostream>
#include <string.h>

using namespace std;

class Cwin
{
    private:
        char id,*title;
    public:
        Cwin(char i='D',char *text="default windows")
        {
            id=i;
            cout<<"件構元被呼叫....."<<endl;
            title=new char[strlen(text)+1];
            strcpy(title,text);
        }
        Cwin(const Cwin &win) //拷貝運算元
        {
            cout<<"拷貝建構元被呼叫...."<<endl;
            id=win.id;
            title=win.title;
            strcpy(title,win.title);
        }
        ~Cwin()
        {
            delete [] title;
        }
        void show()
        {
            cout<<"Windows= "<<id<<" : "<< title <<endl;
        }
};
int main()
{
    Cwin *ptr1=new Cwin('A',"主要的視窗");
    Cwin *ptr2=new Cwin(*ptr1);

    ptr1->show();
    ptr2->show();

    delete ptr1;
    cout<<"刪除prt1之後..."<<endl;

    ptr2->show();
    delete ptr2;
    return 0;
}
