Solve this programming question in c++
Use the code provided below to make further changes #include 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);=""><"enter the="" name:="" ";="" getline="" (cin,="" name);="">"enter><"enter the="" age:="" ";="" cin="">>age; p1.set_name(name); p1.set_age(age); Person p3("Suman Devi",24),p4("Amit Singh",42); //vector initialization vector vec = {p1, p2, p3, p4}; sort(vec.begin() ,vec.end(), compareName); //printing sorted vector int i = 1; for(Person x : vec) { cout <>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 outthe information for one person in the main"enter>
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 outthe information for one person in the main
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here