Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

What are the components of ROI and how do we use ROI for analysis?

Answered: 1 week ago

Question

4. Are there any disadvantages?

Answered: 1 week ago

Question

3. What are the main benefits of using more information technology?

Answered: 1 week ago

Question

start to review and develop your employability skills

Answered: 1 week ago