1.

What is the output of this program?
#include <iostream>
using namespace std;
class ThreeDExample
{
int P, Q, R;
public:
ThreeDExample() { P = Q = R = 0; }
ThreeDExample(int m, int n, int o) { P = m; Q = n; R = o; }
ThreeDExample operator()(ThreeDExample obj);
ThreeDExample operator()(int num0, int num1, int num2);
friend ostream &operator< };
ThreeDExample ThreeDExample::operator()(ThreeDExample object)
{
ThreeDExample temp;
temp.P = (P + object.P) / 2;
temp.Q = (Q + object.Q) / 2;
temp.R = (R + object.R) / 2;
return temp;
}
ThreeDExample ThreeDExample::operator()(int num0, int num1, int num2)
{
ThreeDExample temp;
temp.P = P + num0;
temp.Q = Q + num1;
temp.R = R + num2;
return temp;
}
ostream &operator< strm << obj.P << ", " << obj.Q << ", " << obj.R << endl;
return strm;
}
int main()
{
ThreeDExample objectA(1, 2, 3), objectB(10, 10, 10), objectC;
objectC = objectA(objectB(50, 150, 250));
cout << objectC;
return 0;
}

A. 30, 81, 131
B. 81, 131, 30
C. 131, 81, 30
D. 81, 30, 131
E. None of these
Answer» B. 81, 131, 30


Discussion

No Comment Found

Related MCQs