code file is attached ....

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

// Errors
C:\Dev-Cpp\include\string.h In constructor `citizen::citizen(char*, char*)':
13 C:\Documents and Settings\crystal\Desktop\Untitled2.cpp at this point in file
C:\Documents and Settings\crystal\Desktop\Untitled2.cpp In function `int main()':
32 C:\Documents and Settings\crystal\Desktop\Untitled2.cpp `citizen citizenA' previously declared here
33 C:\Documents and Settings\crystal\Desktop\Untitled2.cpp redeclaration of `citizen citizenA'
C:\Dev-Cpp\include\string.h In constructor `citizen::citizen(char*, char*)':

you declared citizenA twice in main().

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.