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

What is the result of the following code in Java? `System.out.println(5 / 0);` What does the `reverse` method do when called on a string in Ruby? The value of fillOpacity lies between ______ Which term defines all the complete bipartite graph that are trees? In Access to Move down one line