SuperTutor

(15)

$15/per page/Negotiable

About SuperTutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Business & Finance See all
Accounting,Business & Finance,Economics,Engineering,HR Management,Math Hide all
Teaching Since: Apr 2017
Last Sign in: 327 Weeks Ago, 4 Days Ago
Questions Answered: 12843
Tutorials Posted: 12834

Education

  • MBA, Ph.D in Management
    Harvard university
    Feb-1997 - Aug-2003

Experience

  • Professor
    Strayer University
    Jan-2007 - Present

Category > Programming Posted 20 May 2017 My Price 10.00

inheritance hierarchy

You will add another type of animal to the inheritance hierarchy we go over in class. The file is attached below. Add code where the comments indicate code should be added.

 

ORIGINALITY COUNTS. Thank you

 

#include <iostream>
#include <string>

using namespace std;

class Animal
{
public:
	virtual void speak()
	{
		cout << "I am an Animal. My sound is unknown." << endl;
	}
};

class Dog : public Animal
{
public:
	virtual void speak()
	{
		cout << "I am a Dog. I say ruff." << endl;
	}
};

class Cat : public Animal
{
public:
	virtual void speak()
	{
		cout << "I am a Cat. I say meow." << endl;
	}
};

class Cow : public Animal
{
public:
	virtual void speak()
	{
		cout << "I am a Cow. I say moo." << endl;
	}
};

// Add your own type of animal class here. Do not use any from above.
// Inherit from Animal and implement a speak() member function.

void talk(Animal& a)
{
	a.speak();
}

void pointerTalk(Animal* a)
{
	a->speak();
}

int main()
{
	Animal thing;
	Dog rover;
	Cat whiskers;
	Cow bessie;
	// Instantiate object here

	Animal* barn[4] = { &thing, &rover, &whiskers, &bessie /* Add object here */};

	for (Animal* a : barn)
	{
		pointerTalk(a);
	}
}

Answers

(15)
Status NEW Posted 20 May 2017 03:05 AM My Price 10.00

-----------

Attachments

file 1495249997-Solutions file.docx preview (51 words )
S-----------olu-----------tio-----------ns -----------fil-----------e -----------Hel-----------lo -----------Sir-----------/Ma-----------dam----------- T-----------han-----------k y-----------ou -----------for----------- yo-----------ur -----------int-----------ere-----------st -----------and----------- bu-----------yin-----------g m-----------y p-----------ost-----------ed -----------sol-----------uti-----------on.----------- Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m o-----------nli-----------ne -----------or -----------inb-----------ox -----------me -----------a m-----------ess-----------age----------- I -----------wil-----------l b-----------e q-----------uic-----------kly----------- on-----------lin-----------e a-----------nd -----------giv-----------e y-----------ou -----------exa-----------ct -----------fil-----------e a-----------nd -----------the----------- sa-----------me -----------fil-----------e i-----------s a-----------lso----------- se-----------nt -----------to -----------you-----------r e-----------mai-----------l t-----------hat----------- is----------- re-----------gis-----------ter-----------ed -----------onÂ----------- th-----------is -----------web-----------sit-----------e -----------Tha-----------nk -----------you----------- -----------
Not Rated(0)