Starting with provided code • Add gender to your class – enum class Gender {man, woman, nonbinary}; – Gender gen as one of your data attributes in your class • Overload the operator>> to read in all 3 attributes of the person – read it in as an int (not in the class) – then set the gen data attribute with that int • Add a get_gender method to your class to return a string • Print the string that corresponds to the
Solve this programming question in c++
Use the code provided below to make further changes #include<bits/stdc++.h> using namespace std; class Person { private: string name; int age; public: Person() { this->name=""; this->age=0; } Person(string name,int age) { this->name=name; this->age=age; } public: void set_name(string name) { this->name=name; } void set_age(int age) { this->age=age; } string get_name() { return this->name; } int get_age() { return this->age; } }; //custon compare function to sort by name bool compareName (Person p1, Person p2) { return (p1.get_name() < p2.get_name()); } int main() { string name; int age; Person p1,p2("Ajay Kumar",21); cout<<"Enter the name: "; getline (cin, name); cout<<"Enter the age: "; cin>>age; p1.set_name(name); p1.set_age(age); Person p3("Suman Devi",24),p4("Amit Singh",42); //
Starting with provided code
• Add gender to your class
– enum class Gender {man, woman, nonbinary};
– Gender gen as one of your data attributes in your class
• Overload the operator>> to read in all 3 attributes of the person
– read it in as an int (not in the class)
– then set the gen data attribute with that int
• Add a get_gender method to your class to return a string
• Print the string that corresponds to the gender when you print out
the information for one person in the main
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)