Create a person class to represent a person. (You maycall the class personType .
ID: 3619226 • Letter: C
Question
- Create a person class to represent a person. (You maycall the class personType.) To simplify things, have theclass have 2 variable members for the person's first andlast name. Include 2 constructors. One should be a defaultconstructor and the other should be one with parameters. Includerespective functions for:
- setting the name,
- getting the name, and
- printing the name on the screen.
Have your main program call these functions to demonstrate how theywork.
Explain how you can replace both constructors with one constructorby using a single constructor with default parameters.
Explanation / Answer
please rate - thanks #include using namespace std; class personType {public: personType(); personType(string,string); string personType::getfirstname(); string personType::getlastname(); void personType::setfirstname(); void personType::setlastname(); void personType::printname(); private: string first,last; }; personType::personType() {first="first"; last="last"; } personType::personType(string f,string l) {first=f; last=l; } void personType::setfirstname() {"Enter first name: "; cin>>first; } string personType::getlastname() {return last; } string personType::getfirstname() {return first; } void personType::setlastname() {"Enter last name: "; cin>>last; } void personType::printname() {coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.