Home / MCQ Bank / Computer
Computer Classes And Objects In C Plus Plus

What will be the output of the following C++ code? #include <iostream> using namespace std; class sample { int width, height; public: void set_values (int, int); int area () {return (width * height);} friend sample duplicate (sample); }; void sample::set_values (int a, int b) { width = a; height = b; } sample duplicate (sample rectparam) { sample rectres; rectres.width = rectparam.width * 2; rectres.height = rectparam.height * 2; return (rectres); } int main () { sample rect, rectb; rect.set_values (2, 3); rectb = duplicate (rect); cout << rectb.area(); return 0; }

Select the best option to verify your answer:
Show Correct Answer
Correct Answer: Option C • 24

Related Computer Questions

Which element embeds a Java applet into the document? The ______ function converts the initial portion of the string pointed to by, to int representation. How a reference is different from a pointer? Which of the following is a valid way to handle errors in Python? Which key on the keyboard can be used to view slide show in Ms PowerPoint?