**AIM: **Write a case study on Overloading Operators and Overloading Functions.

### OPERATOR OVERLOADING

Operator overloading is x syntactic sugar, and is used because it allows programming using notation nearer to the target domain and allows user-defined types a similar level of syntactic support as types built into a language. It is common, for example, in scientific computing, where it allows computing representations of mathematical objects to be manipulated with the same syntax as on paper.

Operator overloading does not change the expressive power of a language (with functions), as it can be emulated using function calls. For example, consider variables a, b, c of some user-defined type, such as matrices:

a + b * c

In a language that supports operator overloading, and with the usual assumption that the ‘*’ operator has higher precedence than ‘+’ operator, this is a concise way of writing:

add (a, multiply (b,c))

However, the former syntax reflects common mathematical usage.

### FUNCTION OVERLOADING

Operator overloading is syntactic sugar, and is used because it allows programming using notation nearer to the target domain and allows user-defined types a similar level of syntactic support as types built into a language. It is common, for example, in scientific computing, where it allows computing representations of mathematical objects to be manipulated with the same syntax as on paper.

Operator overloading does not change the expressive power of a language (with functions), as it can be emulated using function calls. For example, consider variables a, b, c of some user-defined type, such as matrices:

a + b * c

In a language that supports operator overloading, and with the usual assumption that the ‘*’ operator has higher precedence than ‘+’ operator, this is a concise way of writing:

add (a, multiply (b,c))

However, the former syntax reflects common mathematical usage.

The example code shows how function overloading can be used. As functions do practically the same thing, it makes sense to use function overloading.

function int generateNumber(int MaxValue) {

return rand * MaxValue

}

function int generateNumber(int MinValue, int MaxValue) {

return MinValue + rand * (MaxValue – MinValue)

}