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
- 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.
- ClassA.h contains the class declaration of ClassA
- ClassB.h contains the class declaration of ClassB which is derived from the ClassA
- test.cpp contains main() and use the ClassA and the ClassB.
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