adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    using namespace std;
    class Car
    {
        public:
        int speed;
    };
    int main()
    {
        int Car :: *pSpeed = &Car :: speed;
        Car c1;
        c1.speed = 1;           
        cout << c1.speed << endl;
        c1.*pSpeed = 2;     
        cout  << c1.speed << endl;
        return 0;
    }

a.

1

b.

2

c.

Both 1 & 2

d.

None of the mentioned

Answer: (c).Both 1 & 2

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?