Arithmetic operators
   overloaded using member
function of a class must have
   one argument as object of
                        class.

         Arithmetic operators
      overloaded using friend
function of a class must have
               two argument.
operator overloading in c++
operator overloading in c++
operator overloading in c++
operator overloading in c++
operator overloading in c++
operator overloading in c++
operator overloading in c++

operator overloading in c++

  • 1.
    Arithmetic operators overloaded using member function of a class must have one argument as object of class. Arithmetic operators overloaded using friend function of a class must have two argument.

Editor's Notes

  • #3 Here the contents of object s and t are added thus + operator is overloaded
  • #4 Here b is an integer type variable it is deducted from a which is held by object thus – operator is overloaded.