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 Box { double width; public: friend void printWidth( Box box ); void setWidth( double wid ); }; void Box::setWidth( double wid ) { width = wid; } void printWidth( Box box ) { box.width = box.width * 2; cout << "Width of box : " << box.width << endl; } int main( ) { Box box; box.setWidth(10.0); printWidth( box ); return 0; }

Select the best option to verify your answer:
Show Correct Answer
Correct Answer: Option D • 20

Related Computer Questions

Which of the following frequency ranges is used for AM radio transmission? The process of communicating with a file from a terminal is What is the role of the shinydashboardPlus package in R? Which of following shows a better runtime performance for coalescing functionality, using functions, and using objects? In Java, what is a daemon thread?