# What is the result of calling these overloaded arithmetic operators

Question | Mar 18, 2017 | rparekh

A struct - Couplet - has two members of type double:

``````struct Couplet {
double x;
double y;
};
``````

The Couplet has some non-member overloaded arithmetic operators ( +, -, *, / ) on it:

``````Couplet operator + (const Couplet& c1, const Couplet& c2) {
return { c1.x + c2.x, c1.y + c2.y };
}

Couplet operator - (const Couplet& c1, const Couplet& c2) {
return { c1.x - c2.x, c1.y - c2.y };
}

Couplet operator * (const Couplet& c1, const Couplet& c2) {
return { c1.x * c2.x, c1.y * c2.y };
}

Couplet operator / (const Couplet& c1, const Couplet& c2) {
return { c1.x / c2.x, c1.y / c2.y };
}
``````

The code below creates few instances of Couplet and calls the arithmetic operators on them in one expression:

``````Couplet c1 = { 5, 7 };
Couplet c2 = { 8, 12 };
Couplet c3 = { 20, 35 };

auto c4 = c1 + c2 * c3 / c1 - c2;
``````

The above expression does not use any parentheses. It is done intentionally to develop the understanding of operator precedence in relation to operator overloading.

What will be the result of above expression or value of `c4`?