1lass Fred {
2public:
3 // ...
4};
5if
6 // Without operator overloading:
7 Fred add(const Fred& x, const Fred& y);
8 Fred mul(const Fred& x, const Fred& y);
9 Fred f(const Fred& a, const Fred& b, const Fred& c)
10 {
11 return add(add(mul(a,b), mul(b,c)), mul(c,a)); // Yuk...
12 }
13else
14 // With operator overloading:
15 Fred operator+ (const Fred& x, const Fred& y);
16 Fred operator* (const Fred& x, const Fred& y);
17 Fred f(const Fred& a, const Fred& b, const Fred& c)
18 {
19 return a*b + b*c + c*a;
20 }
21#endif