-
What is the output of this program?
#include
using namespace std;
class Example
{
public:
int m, n;
Example() {};
Example(int, int);
Example operator + (Example);
};
Example::Example (int p, int q)
{
m = p;
n = q;
}
Example Example::operator+ (Example parameter)
{
Example container;
container.m = m + parameter.m;
container.n = n + parameter.n;
return (container);
}
int main ()
{
Example p (3,4);
Example q (6,5);
Example R;
R = p + q;
cout << R.m << "," << R.n;
return 0;
}
-
- 9,9
- 3,4
- 6,5
- Compilation Error
- None of these
Correct Option: A
In this program, we are adding the first number of p with first number of q by using operator function and also we are adding second number by this method also.