Given the following classes and code, what is the output of the last statement shown?
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;
}
Pet* pPtr;
Dog* dPtr=new Dog;
DPtr->name= "Rover";
DPtr->breed="Weiner";
PPtr= dPtr;
PPtr->print) ;
A) My name is Rover, and my breed is a Weiner
B) My name is Rover
C) , and my breed is a Weiner
D) nothing
Correct Answer:
Verified
Q40: If the member variables in a base
Q41: If a base class has a virtual
Q42: If you have a copy constructor in
Q43: If a base class has a non-virtual
Q44: If a derived class Class2) has redefined
Q46: Given the following classes and code, what
Q47: Given a class A that derives from
Q48: Which of the following would correctly call
Q49: Which of the following should be virtual
Q50: In order to tell the compiler to
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents