#include<iostream>
using namespace std;
class citizen{
      char* name;
      char* nationality;
      public:
             citizen(){
                       name="Usman";
                       nationality="pakistani";
                       }
             citizen(char * aName, char * aNationality)
             {
                          name = new char[strlen(aName, aNationality)+1];
                          strcpy(name,aName);
                          strcpy(nationality,aNationality);
                          }
                          citizen(const citizen &obj){
                          name = obj.name;
                          nationality =obj.nationality;
                          }
                          void showName(){
                               cout<<name<<endl;
                               }
                          ~citizen()
                          {
                                    delete[]name;
                                    }
                                    };
          int main()
          {
              citizen citizenA;
              citizen citizenA("irshad","Pakistani");
              citizen citizenB = citizenA;
              citizenA.showName();
              citizenB.showName();
              system("pause");
              return 0;
          }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

I'm sorry did you have a question or some compiler errors to post.

Also putting code tags round your code makes it more easy to read.

Edited 3 Years Ago by happygeek: fixed formatting

This article has been dead for over six months. Start a new discussion instead.