a it let you to provide an intuitive interface to


A: It let you to provide an intuitive interface to users of your class, as well as makes it possible for templates to equally work well with classes and built-in/intrinsic types.

Operator overloading let C/C++ operators to have user-defined meanings on user-defined types (classes). Overloaded operators are syntactic sugar for function calls:

class Fred {                      

public:

...

};

#if 0

// Without operator overloading:

Fred add(const Fred& x, const Fred& y); Fred mul(const Fred& x, const Fred& y);

Fred f(const Fred& a, const Fred& b, const Fred& c)

{

return add(add(mul(a,b), mul(b,c)), mul(c,a)); // Yuk...

}

#else

// With operator overloading:

Fred operator+ (const Fred& x, const Fred& y); Fred operator* (const Fred& x, const Fred& y);

Fred f(const Fred& a, const Fred& b, const Fred& c)

{

return a*b + b*c + c*a;

}

#endif

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: a it let you to provide an intuitive interface to
Reference No:- TGS0217711

Expected delivery within 24 Hours