adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #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;
   }

a.

40

b.

5

c.

10

d.

20

Answer: (d).20

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?