Answered step by step
Verified Expert Solution
Question
1 Approved Answer
animals.cpp: #include #include Dog.h using namespace std; int main(int argc, const char * argv[]) { Dog myDog = Dog(Bruno, 4); cout Animal.h: #pragma once
\
animals.cpp:
#include#include "Dog.h" using namespace std; int main(int argc, const char * argv[]) { Dog myDog = Dog("Bruno", 4); cout
Animal.h:
#pragma once #include
#include #include using namespace std;
class Animal { string name; int age;
public:
Animal() { cout
void display(const vector
& list) { }
string getName() { return name; }
void setName(string name) { this->name = name; }
int getAge() { return age; }
void setAge(int age) { this->age = age; }
~Animal() { cout
void feed() { cout
};
Get the file Animal.h. It contains an Animal class that stores the name and age of an animal. Besides the appropriate constructors, getters, and setters it has a function called feed() which prints out the message "Some meal, please!!". Dogs are animals too, so we can extend the Animal class to produce a Dog class. We only need to change the constructors and destructors of the Dog class to print the appropriate messages and we need to change the feed() function to print a message saying "A small bone, please!" Your class should be stored in a file called Dog.h. Your solution will be tested with the file animals.cpp. Sample output from animals.cpp Creating Generic Animal Creating Dog Bruno is 4 years old. A small bone, please!! Deleting Dog Deleting Generic Animal
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started