Output of this program?
#include <iostream>
using namespace std;
class Integer
{
int i;
public:
Integer(int ii) : i(ii) {}
const Integer
operator+(const Integer& rv) const
{
cout << "operator+" << endl;
return Integer(i + rv.i);
}
Integer&
operator+=(const Integer& rv)
{
cout << "operator+=" << endl;
i += rv.i;
return *this;
}
};
int main()
{
int i = 1, j = 2, k = 3;
k += i + j;
Integer ii(1), jj(2), kk(3);
kk += ii + jj;
}
a) operator+
operator+=
b) operator+=
operator+
c) operator+
operator+
d) None of the mentioned
Submitted by: Administratora) operator+
operator+=
Submitted by:
operator+=
Submitted by:
Read Online C++ Operator Overloading Job Interview Questions And Answers
Top C++ Operator Overloading Questions
☺ | Pick the other name of operator function. |
☺ | What is overloading template? |
☺ | Can you please explain the difference between overloaded functions and overridden functions? |
☺ | Explain overloading unary operator? |
☺ | Can you please explain function overloading? |
Top C Plus Plus Language Categories
☺ | C++ Pointers & Functions Interview Questions. |
☺ | C++ Operator Overloading Interview Questions. |
☺ | C++ Exception Handling Interview Questions. |
☺ | C++ Template Interview Questions. |
☺ | C++ Virtual Functions Interview Questions. |