Question: C++ please help Given the following classes and code, what is the output of the program? Explain why you have gotten your answer. class Pet

C++ please help

Given the following classes and code, what is the output of the program? Explain why you have gotten your answer.

class Pet

{

public:

virtual void print();

string name;

private:

};

class Dog: public Pet

{

public:

void print();

string breed;

};

void Pet::print()

{

cout << "My name is " << name;

}void Dog::print()

{

Pet::print();

cout << ", and my breed is a "<< breed << endl;

}

int main() {

Pet pet;

Dog dog;

dog.name = "Rover";

dog.breed = "Weiner";

pet = dog;

pet.print();

cout << " ";

Pet* pPet = &dog;

pPet = &dog;

pPet->print();

return 0;

}

. Assuming a correct implementation of the two classes in the question above, which of the following correctly initialize the static data member, count?

a. int count = 0;

b. Rectangle:count = 0;

c. int Rectangle::count = 0;

d. static int Rectangle::count = 0;

e. None of above

  1. Suppose that your project consists of ClassA.h, ClassA.cpp, ClassB.h, ClassB.cpp, and test.cpp that contains main(). Write a makefile to perform separate compilation for this project. In addition, assume the following in order to create your makefile.
  1. ClassA.h contains the class declaration of ClassA
  2. ClassB.h contains the class declaration of ClassB which is derived from the ClassA
  3. test.cpp contains main() and use the ClassA and the ClassB.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!