Answers

Question and Answer:

  Home  C++ Operator Overloading

⟩ Output of Program? #include <iostream> using namespace std; class sample { public int x, y; sample() {}; sample(int, int); sample operator + (sample); }; samplesample (int a, int b) { x = a; y = b; } sample sampleoperator+ (sample param) { sample temp; temp.x = x + param.x; temp.y = y + param.y; return (temp); } int main () { sample a (4,1); sample b (3,2); sample c; c = a + b; cout << c.x << "," << c.y; return 0; } a) 5, 5 b) 7, 3 c) 3, 7 d) None of the mentioned

b) 7, 3

 243 views

More Questions for you: