Question: Given the following header file: Animals.h #ifndef ANIMALS_H #define ANIMALS_H #include class Animal { public: Animal ( const std::string& name ) : fname (
Given the following header file: Animals.h #ifndef ANIMALS_H #define ANIMALS_H #include class Animal { public: Animal ( const std::string& name ) : fname ( name ) {} virtual void Speak () const = 0; protected: std::string fName; }; // class Animal class Dog : public Animal { public: Dog ( const std::string& name ) : Animal ( name ) {} virtual void Speak () const; }; // class Dog class Cat : public Animal { public: Cat ( const std::string& name ) : Animal ( name ) {} virtual void Speak () const; }; // class Cat class Tiger : public Animal { public: Tiger ( const std::string& name ) : Animal ( name ) {} virtual void Speak () const; }; // class Tiger void TestAnimals (); #endif (a) Draw a Class Diagram to represent the objects declared. [50] (b) Define the TestAnimals () function to produce the following: [50] woof! My name is Rover. Meow! My name is Tabby. Roar! My name is Mike. Meow! My name is Tabby Jr. Woof! My name is Rover Jr. (c) Rewrite the above in Java. [Extra credit 20]
Step by Step Solution
3.42 Rating (155 Votes )
There are 3 Steps involved in it
a b include include using namespace std class Animal publi... View full answer
Get step-by-step solutions from verified subject matter experts

