Vidyalelo
C++ Programming · Q69

Classes and Objects in C++

Programming · C++ Programming · question 69

Q69

#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
Answer
B.
55, 106
C.
55, 106, 159
D.
55, 106, 158

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board