operator overloading fundamentalsthe c language


Operator Overloading Fundamentals

The C language uses the concept of Operator Overloading

discreetly. The asterisk (*) is used as multiplication operator as well as indirection (pointer) operator. The ampersand (&) is used as address operator and also as the bitwise logical 'AND' operator. The compiler decides what operation is to be performed by the context in which the operator is used.

Therefore, the C language has been using Operator Overloading internally. Now, C++ has made this facility public. C++ can overload existing operators with some other operations. If the operator is not used in the context as explained by the language, then the overloaded operation, if explained will be carried out.

For example, in the statement

                x = y + z;

If x, y and z are integer variables, then the compiler knows the operation to be performed. But, if they are objects of some class, then the compiler will carry out the instructions, which will be written for that operator in the class.

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: operator overloading fundamentalsthe c language
Reference No:- TGS0309394

Expected delivery within 24 Hours