114. Operator Overloading-II

Question.6

A developer worries that operator overloading adds runtime cost compared to a plain function call:

// Function call
Vec add(const Vec& a, const Vec& b) { return Vec(a.x+b.x, a.y+b.y); }
Vec c = add(v1, v2);

// Operator overload
Vec c = v1 + v2;  // Calls v1.operator+(v2)

Is there a performance difference?

Need Help? Refer to the Quick Guide below

Select Answer