-
What is the output of this program?
#include
using namespace std;
class Example
{
int K;
public:
Example(int KK) : K(KK) {}
const Example
operator+(const Example& rv) const
{
cout << "operator++" << endl;
return Example(K + rv.K);
}
Example&
operator+=(const Example& rv)
{
cout << "operator++=" << endl;
K += rv.K;
return *this;
}
};
int main()
{
int K = 2, L = 3, k = 4;
k += K + L;
Example KK(2), LL(3), MM(4);
MM += KK + LL;
}
-
- operator++
- operator++=
- operator++=
operator++ - operator++
operator++= - None of these
Correct Option: C
We are using two operator functions and executing them and the result is printed according to the order.