Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MULTIPLE CHOICE C++: Please select correct answer and with small explanation. If the following function is in a base class, which of the following are
MULTIPLE CHOICE C++: Please select correct answer and with small explanation.
If the following function is in a base class, which of the following are polymorphic declarations of the same function in the derived class? 5. Explain your answer. virtual void print( ostream& out) a. virtual void print (ostream& out); b. void print( ostream& out); c. void print); d. virtual void print0 e. A and B f. A and D 6. Given the following classes and code, what is the output of the program? Explain how you get the answer class Pet int main) Pet* pPet; Dog pPet pDog; public: Pet(); Pet(string); void print); pDog - new Dog("Rover", "Doodle"); private: 1; Pet: Pet() pPet->print); return ; string name; 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 name Pet::Pet(string newName) namenewName 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 " 3 using namespace std; 4 5 class Base 6 public: int x; int getY); int getz); 10 protected: int y; 12 private: 13 14 1; 15 16 Base:Base) x(10), y (20), z(30) 17 18 19 int Base::gety) int z; return y; 21 22) 23 24 int Base: :getz() 25 26 27 28 29 class Child: protected Base f 30 public: 31 32 33 int getz); 34 private: 35 36; 37 38 Child: :Child( B, r(100) 39 40 41 int Child::getR() 42 43 return Z; int getR int getX); int r; return r 45 int Child::getX() 46 47 48 49 50 int main() 51 52 53 cout class A public B ( public: AO; ~A) 3; A: :A) cout A::A) f cout
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