Why is copy constructor not being called in this code
So why is Copy constructor not being invoked in " const Integer operator+(const Integer &rv) " function. Is it because of RVO. If Yes what do I need to do to prevent it? #include <iostream> using namespace std; class Integer { int i; public: Integer(int ii = 0) : i(ii) { cout << "Integer()" << endl; } Integer(const Integer &I) { cout << "Integer(const Integer &)" << endl; } ~Integer() { cout << "~Integer()" << endl; } const Integer operator+(const Integer &rv) const { cout << "operator+" << endl; Integer I(i + rv.i); I.print(); return I; } Integer &operator+=(const Integer &rv) { cout <<