Networking, Programming and Graphics Tutorials

Overloading binary operator using friend function - C++ [1/1]

Type:
Overloading binary operator using friend function - C++
Level: Intermediate Networking, Programming and Graphics Tutorials Networking, Programming and Graphics Tutorials 
Overloading binary operator using friend function - C++
Date: 2006-Dec-08
Overloading binary operator using friend function - C++
Visited: 1375 times
Overloading binary operator using friend function - C++
Rating: Overloading binary operator using friend function - C++
Overloading binary operator using friend function - C++
Author: Alex Plumpton

In the example using class adds, friend function can be used in the place of member function to overload the binary operator +. The difference is that the friend function requires two arguments while the member function requires only one. In the example using class adds, the member function declaration can be replaced by the friend function declaration as shown. The function definition has to be replaced as shown.

friend adds operator +(complex a1complex a2);
Parts operator +(adds a1adds a2)
{
return 
add((a1.m+a2.m),(al.n+p2.n));
}
Rate this tutorial:                    
Networking, Programming and Graphics Tutorials - Overloading binary operator using friend function - C++ [1/1] - Networking, Programming and Graphics Tutorials

Need a specific tutorial? Do not hesitate and submit a request!
Related Tags: binary Operator Overloading using friend function  c++ overloading binary * operator  Overloading binary operator >  "binary operator" overloading == C++  binary operator overloading in c++  example of binary * operator overloading in c++  friend operator in c++  c++ friend operator  C++ binary operator  c++ "operator<" redefinition binary  c++ operator overload binary  overloading friend function+ c++ tutorial+example  explain about operator overloading and function overloading with examples  function name and operator overloading in C++  c++ overloading function operator  function operator + overloading C++  function and operator overloading in c++  function and operator overloading in c++  friend overloading c++  function over loading and operator overloading in cpp