Q174
What will be the output of the following C++ code? #include 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;
A.
40
B.
5
C.
10
D.
20
AnswerAnswer: Option D
Solution
Answer: Option D
No explanation is given for this question Let's Discuss on Board