adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include 
    using namespace std;
    class three_d 
    {
        int x, y, z;
        public:
        three_d() { x = y = z = 0; }
        three_d(int i, int j, int k) { x = i; y = j; z = k; }
        three_d operator()(three_d obj);
        three_d operator()(int a, int b, int c);
        friend ostream &operator<<(ostream &strm, three_d op);
    };
    three_d three_d::operator()(three_d obj)
    {
        three_d temp;
        temp.x = (x + obj.x) / 2;
        temp.y = (y + obj.y) / 2;
        temp.z = (z + obj.z) / 2;
        return temp;
    }
    three_d three_d::operator()(int a, int b, int c)
    {
        three_d temp;
        temp.x = x + a;
        temp.y = y + b;
        temp.z = z + c;
        return temp;
    }
        ostream &operator<<(ostream &strm, three_d op) {
        strm << op.x << ", " << op.y << ", " << op.z << endl;
        return strm;
    }
    int main()
    {
        three_d objA(1, 2, 3), objB(10, 10, 10), objC;
        objC = objA(objB(100, 200, 300));
        cout << objC;
        return 0;
    }

a.

55, 106, 156

b.

55, 106

c.

55, 106, 159

d.

none of the mentioned

Answer: (a).55, 106, 156

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?