Solved by Expert Tutors
Solved by Expert Tutors
Question

you will be creating 3 classes. Use the main funciton below to guide your design.

  • Create and write member functions for an abstract Human class. The class should contain:
  • Data members to store the name and age of the Human
  • Any necessary constructors or destructor
  • A virtual accessor function, Name(), to return the name
  • A pure virtual function, called gender() 
  • A non-virtual function, Type(), that returns the string, "human"
  • Create and write member functions for a Male class. The class should be derived from the Human class. Add the necessary functions. Override the Type() function so that it returns "Male". The gender() function should print "I am male".
  • Create and write member functions for a Female class. The class should be derived from the Human class. Add the necessary functions. Do not override the Type(). The gender() function should print "I am female".

Here is the main function:

int main()

{

Male B("George");

Female G("Sally");

Human* pp;

cout << B.Name() << endl; 

cout << B.Type() << endl; 

B.gender(); 

pp = &B;

cout << pp->Name() << endl;

cout << pp->Type() << endl;

pp->gender(); 

pp = &G;

cout << pp->Name() << endl;

cout << pp->Type() << endl;

pp->gender(); 

}


    What is the program output? Write out each line of output.

Step-by-step answer

consectetur adipiscac, dec aliqueec

icitoneclestie consequat,concing elit. Net, consectetur adipiscing elit. Nam lacinia pulvinars a molesticonsum dolor sit amiaac, dictum vitae odio. Donec aliqueconFusce dui lectus, congue vel laoreet ac, dictum vitae odio. Done0molestie consequat, ultrices ac magna.ec facisumitriicia moleo. Donec aliquet. Lorem ipsum dolor sit amet, consectetdictum vitae odio. Door nefficitur laoreet. Nam risus ante, dapibus a moec faciur lisumicig0insus ante, dapibus a moinia pulvinar tortor necsumiceicec, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, codictum vitae odio. Door nelrem ipmolestie consequat, ultrices ac magna.at, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictor neonecconsectconlestie consequat,conec facilisis. Pellentesque dapiconm ipsum dolor sit amet, consectetur adipisciur lisumicecacinia pulvinar tortor nec facilisis. Pellentesqudictum vitae odio. Donecec fnec facilismolestie consequat, ultrices ac magna.sumiceicectrices ac magna. Fusce dui lectus, congue vel laoreet ac,dictum vitae odio. Door nelconmolestie consequat, ultrices ac magna.at, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dicta molestonecusce duiconlestie consequat,connec facilisis. Pellentesque dapiconpulvinar tortor nec facilisis. Pellentesquur lisumicecdictum vitae odio. Donec aliquet. Lorem ipsum dolordictum vitae odio. Donecec fusce dui lectusmolestie consequat, ultrices ac magna.risus ante, dapibuinia pulvinar tortor necat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dicta molest,iceiciac, dictum vur laoxac, dictttrices ac maamet, c,xnec fattrices ac magna. Fusce dui lectusnecec facilisis. Pedictricesnec facilisis. Pelles a molestinecec facilisis. Pedictricestrices ac magna. Fusce dui lectus, congue vel laoreur laoreet. Nam risus aonec aliquet. Lorem ipsum dolor sit amet, cofacilisis. Pellentesque dapibnecrem ipsum dolor sidicinet, consectetur adipis a molestinectrices ac magna. Fdicinnec facilisis. Pellentesque dapibus efficrem ipsum dolor sit amet,onec aliquet. Lorem ipsum dolor sit amet, coet, consectetur adipiscing elinecrem ipsum dolor sidicin, dictum vitae odis a molestinectrices ac magna. Fdicinat, ultrices ac magna. Fusce dui lectus, congue vel laoreetrem ipsum dolor sit amet,facilisis. Pellentesque dapibus efficitur laour lo. Donec ali

trices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vi


ffic

ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laor

s a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risu

sum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec alique

ur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus

s a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risu

consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor si

ur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus

sum dolor sit ame


C++.PNG


fficitur laoreet. Nam

iscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec a

nec facilisis. Pellentesque da

C++.PNG
r

Subscribe to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Let our 24/7 Computer Science tutors help you get unstuck! Ask your first question.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes