Vidyalelo
C++ Programming · Q524

C++ miscellaneous

Programming · C++ Programming · question 524

Q524

What will be the output of the following C++ code? #include using namespace std; class p protected: int width, height; public: void set_values (int a, int b) width = a; height = b; virtual int area (void) = 0; ; class r: public p public: int area (void) return (width * height); ; class t: public p public: int area (void) return (width * height / 2); ; int main () r rect; t trgl; p * ppoly1 = ▭ p * ppoly2 = &trgl; ppoly1->set_values (4, 5); ppoly2->set_values (4, 5); cout area() ; cout area(); return 0;

A.
1020
B.
20
C.
10
D.
2010
Answer

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board