Tuesday 31 March 2015

OPERATOR OVERLOADING

The Basics for Operator Overloading

The operator overloading feature of C++ is one of the methods of realising polymorphism. Here poly refers to many or multiple and morphism refers to action. i.e., performing many actions with single operator.

The concepts of operator overloading can also be applied to data conversion. C++ refers automatic conversion of primitive data types. For example, x = a+ b, the compiler implicitly converts the integer result to floating point representation and then assigns to float variable x.

The operator overloading concepts are applied to the following two principal areas.

? The extending capability of operators to operate on user defined data.

? Data conversion

Operator overloading extends the semantics of operator without changing, its syntax. The grammatical rules defined by C++ that govern its use such as the number of operands, precedence, and associativity of the operator remain the same for overloaded operators.

No comments:

Post a Comment