Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider a Person.t structure where a person object has a first name, a last name, a date of birth, a profession, and a list
Consider a Person.t structure where a person object has a first name, a last name, a date of birth, a profession, and a list of hobbies. Randomly generate a vector of 1, 000 persons (a skeleton is provided). 3 Create an STL map where Person.t objects are ordered by their last names and then by their first names. Recall that you need to provide an implementation of bool operator skeleton code: #include #include #include #include #include #include #include #include using namespace std struct date int day; int month; int year, date(int d = 0, int m= 0, int y = 0) { day = d; month = m; year = y: } date(const date & d) { day = d.day: month = d.month: year = d.vear. }: date date2(0, 0, 0); struct Person t string first; string last; date d; string profession; vector hobby, Person t(string f= "", stringl = date d1 = date(date2), string pro = "") !! d day = d1.day; d. month = d1.month; d.vear = d1.year, first = f; last = 1; profession = pro; !! int main() cout < < "Problem 2:" < < endl < < end: srand(time(0)); //seed vector hobby; hobby push back("basket"); hobby, push back("running"); hobby. push back("piano"): hobby, push back("drawing"); hobby. push back('reading"); hobby. push back('writing"); hobby. push back('programming! :) "); vector prof. prof.push_back("teacher"); prof push back("lawyer"): prof push back("doctor"); prof push back("engineer"): prof.push back("economist"); prof push back("politician"); lleverything in comments below must be completed vector v; for (int i = 0; i < 1000; i++) { lint d=; lint m = Ilint y = ; date date(d, m, y): string first = "". for (int i = 0; i < 8; i++) { ifirst =; string last = "". for (int i = 0; i < 8; i++) { ilast =; string pro; pro = proffrand) % 6]; int h = 1 + rand() % 8; Person t p(first, last, date, pro); for (int i = 0; i < h; i++) { i(p.hobby). push back0: } Ily.push back0: } return 0; }
Step by Step Solution
★★★★★
3.44 Rating (163 Votes )
There are 3 Steps involved in it
Step: 1
Here is the completed code for this problem Rewrote the overall structure of the program also added new constructors and getters setters as mentioned ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started