/*operator overloading is an important concept in c++.it is a type of polymorphism in which operator
is overloaded to give user define meaning to it.overloaded operator is used to perform operation on
user defined data types.the meaning of operator are already define for basic data type like int,
float,char,string.if you want add two integer then use the + operator.but for user define data type
like object,you can define the meaning of operator.you can redefine the way in whic operator work.
to overload the operator operator function define inside the class.
for example:
class test
{
return-type operator-keyword operator-sign(arguments )
{
}
};
operator function must be either friend function or non static member function.if the operator
function is the friend function then it will have one arrgument for unary operator and two arrgument
for binary operator.if the operator function is a non static member function then it will have no
arrgument for unary operator and one arrgument for binary operator.
some operator cannot be overloaded (.) (::) (sizeof) (.*) (?:).
we cannot use friend function to overload these operator.
(=) (()) ([]) (->).
when binary operator overloaded through member function the left hand operend must be the object
of a class.
*/
No comments:
Post a Comment