Operator Functions

6

What is the output of this program?

1.
        #include 
2.
        using namespace std;
3.
        class sample 
4.
        {
5.
            public:
6.
            int x, y;
7.
            sample() {};
8.
            sample(int, int);
9.
            sample operator + (sample);
10.
        };
11.
        sample::sample (int a, int b) 
12.
        {
13.
            x = a;
14.
            y = b;
15.
        }
16.
        sample sample::operator+ (sample param) 
17.
        {
18.
            sample temp;
19.
            temp.x = x + param.x;
20.
            temp.y = y + param.y;
21.
            return (temp);
22.
        }
23.
        int main () 
24.
        {
25.
            sample a (4,1);
26.
            sample b (3,2);
27.
            sample c;
28.
            c = a + b;
29.
            cout << c.x << "," << c.y;
30.
            return 0;
31.
        }
A. 5, 5
B. 7, 3
C. 3, 7
D. None of the mentioned

7

How to declare operator function?

A. operator operator sign
B. operator
C. operator sign
D. None of the mentioned

8

Which of the following operators can't be overloaded?

A. ::
B. +
C. -
D. []

9

Pick the other name of operator function.

A. function overloading
B. operator overloading
C. member overloading
D. None of the mentioned