Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have the code but it is not compiling and has many error messages could someone help, I need to compile the 3 cpp files

image text in transcribed

image text in transcribed

image text in transcribed

I have the code but it is not compiling and has many error messages could someone help, I need to compile the 3 cpp files with the g++ and it will not work... Please show its working thank you!

CODE:

lab8dog.h

#include using namespace std;

class Dog { protected: string name; string color; double weight; public: Dog(); Dog(string,double,string); virtual void displayDog(); virtual ~Dog(); };

lab8show.h

class ShowDog:public Dog { private: int noContests; int winContests;

public: ShowDog(); ShowDog(string,double,string,int,int); void displayDog(); };

lab8dog.cpp

#include "lab8dog.h" Dog::Dog(){ name="unknown"; color="unknown"; weight=0.0; } Dog::Dog(string n,double w,string c){ name=n; color=c; weight=w; } void Dog::displayDog(){ coutname; cout

lab8show.cpp

#include "lab8show.h" #include using namespace std;

ShowDog::ShowDog():Dog() { noContests=0; winContests=0; } ShowDog::ShowDog(string n,double w,string c,int total,int win): Dog(n,w,c) { noContests=total; winContests=win; } void ShowDog::displayDog() { cout

lab8client.cpp

#include "lab8show.cpp" int main(){ Dog D("Bolt", 20,"White"); D.displayDog();

ShowDog SD("Uggie", 30, "Blk/Wht", 3, 1 ); SD.displayDog();

Dog *dogList[4];

Dog *temp; // temp=new Dog("Bingo", 20, "Tan"); dogList[0]=new Dog("Bingo", 20, "Tan");; dogList[1]= new ShowDog("Beethoven", 200, "Brown",3,1);

dogList[2]= new ShowDog("Marley", 80, "Yellow",10,3);

dogList[3]= new Dog("Fido", 50, "Rust");

for(int i=0;idisplayDog(); cout

return 0; }

Mandatory Instructions 1. The base class Dog is a class with general information about dogs Store the declaration for this class in a file called labSdog.h. The class has three protected data members to store dog's name, color and weight Include a prototype fora default constructor that sets the name and color to the value "Unknown" and the weight to 0.0. Include a second prototype for a constructor that accepts values for the dog's name, color and weight and assigns them to the data members. Also, include a prototype for a function called displayDog to display the values of each data member. 2. Implement all member fiunctions for the Dog class in the file called lab8dog.cpp 3. Class ShowDog will be a derived class with additional information about dogs who have been entered in dog shows so a ShowDog"is a" Dog which means it will inherit from the Dog base class. Store the declaration for the ShowDog class in the file lab8show.h and define the functions in the file lab8show.cpp This class has two private data members -the number of contests a dog has been entered in and the number of contests it has won. Define a default constructor that sets these two fields to zero and invokes the Dog default constructor to initialize the inherited data members. Define a second constructor that accepts a dog's name, color, weight, number of contests entered and number won. Pass the first three arguments to the Dog constructor and use the last two to set the ShowDog's data members. Include a prototype for a function called displayDog. It should first call the base class version of the function (to display the dog's name, color and weight) and then display the mmber of contests entered by the dog and the number won. This function is redefining the base class version of displayDog. The function should produce an output like this: Dog's name: Toto Dog's weight: 25 Dog's color: Grey (first three lines are printed by base class displayDog function) Toto was entered in 5 contests, Toto won 2 of the contests. 4. Write a client program called labSclient.cpp to demonstrate the use of Dog and ShowDog classes. Define a Dog object initializing the name, color and weight with "Bolt", "White" and 20 Define a ShowDog object with arguments for all five data members using the values "Uggie", "Blk/Wht", 30, 3, 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions