Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[c++] Given the following classes and code, what is the output of the program? Explain how you get the answer in detail and if any

[c++] Given the following classes and code, what is the output of the program? Explain how you get the answer in detail and if any problems what can be done to fix it.

class Pet

{

public:

Pet();

Pet(string);

void print();

private:

string name;

};

Pet::Pet() {

name = "";

}

Pet::Pet(string newName) {

name = newName;

}

class Dog: public Pet

{

public:

Dog(); Dog(string, string);

void print();

private:

string breed;

};

Dog::Dog() : Pet(), breed("") {

}

Dog::Dog(string newName, string newBreed) : Pet(newName), breed(newBreed)

{

}

void Pet::print()

{

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

}

void Dog::print()

{

Pet::print();

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

}

int main() {

Pet* pPet;

Dog* pDog = new Dog("Rover", Doodle);

pPet = pDog;

pPet->print();

return 0; }

a. My name is Rover, and my breed is a Doodle

b. My name is Rover

c. , and my breed is a Doodle

d. Nothing

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_2

Step: 3

blur-text-image_3

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

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

2. Explain grades or test results.

Answered: 1 week ago

Question

Discuss how selfesteem is developed.

Answered: 1 week ago