Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

4.5. Inline Functions

Here is a possible implementation of the addition operator for our Point class:

class Point { 
   friend Point 
       operator+( const Point&, const Point& ); 
   ... 
}; 

Point 
operator+( const Point &lhs, const Point &rhs ) 
{ 
   point new_pt; 

   new_pt._x = lhs._x + rhs._x; 
   new_pt._y = lhs._y + rhs._y; 

   return new_pt; 
} 


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial