The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 6 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
C++ programing problem
Project 2: Pet
The class Pet represents a domesticated animal. As you'll from its class diagram, it is a concrete (instantiatable) class which might represent a household animal. The class Dog is a much more specific kind of Pet that identifies an animal of canine variety. Following the diagrams show below, create the classes Pet and Dog. A sample driver has been provided to guide your efforts. IN ORDER TO RECEIVE FULL CREDIT, YOUR SUBCLASS MUST CALL ITS PARENT CONSTRUCTOR AS WELL AS REUSE ITS PARENT'S PROTECTED MEMBERS.

| Pet | Â Â | Dog |
|
Pet( ); std::string getName( ) const; |
 |
Dog( ); virtual std::string speak( ); |
|
// THESE ARE PROTECTED!!! |
 |
// BY DEFAULT, DOG'S ARE |
| Driver Code |
|
Pet * p = new Pet( "Sunset", "Cat", "meow..." ); cout << "The " << p->getVariety( ) << " " << p->getName( ) << " speaks by saying " << p->speak( ) << endl; cout << "The " << d->getVariety( ) << " " << d->getName( ) << " speaks by saying " << d->speak( ) << endl; |
| Sample Output |
| The Cat Sunset speaks by saying meow... The Canine Muffin speaks by saying Bark |
Â
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll