#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;
          }

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.