Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program in which you arerequired to define a class named Citizen . T

ID: 3618488 • Letter: W

Question

Write a C++ program in which you arerequired to define a class named Citizen. The class mustinclude the following two data members.

// data member for Citizen Name

1: Name

//data member for Citizen Nationality

2: Nationality

Your Program should define threeconstructors for the class Citizen

1: a constructor with no parameter

2: a constructor with two parameters (name,nationality)

3: a copy constructor

All of these three constructors aremeant to initialize their respective objects. Incase of copyconstructor, you are required to assign a separate space for thedata members of the new object while copying the values ofpreviously existed object.

Declare three objects (1 for eachtype of constructor) in main.

Write a function in classCitizen todisplay the initialized data members for each object.

Also write destructor for the classCitizen.Display a message that says “destructor called” inthe destructor body.

Note:- Make use ofcomments in source code where you use constructors , objects, copyconstructors and destructors.

Explanation / Answer

#include using namespace std; class Citizen{       private:          string name;          stringnationality; public:         Citizen(string n,stringnat)           {name=n;           nationality=nat;            }         Citizen()           {name="name";           nationality="nation";            }          Citizen(constCitizen &n)            {name=n.name;            nationality=n.nationality;            }        void display()           {cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote