latest Post

C + + part 9 ( operator overloading - using friend function )








So hey guys let's get serious i am just joking we are going to complete the 10 article in the series and the article may not be regular because my exams are going on so the next article is coming after a week so don't forget  to see it and if you are new to this blog then you can the other parts of the series YOU CAN CHECK ON BELOW IN THE LINK so don't forget to see them if not .
So let's go.................................................................................................................................................

ALL THE ARTICLES ARE HERE

THE PREVIOUS ONE ARTICLE IS ABOUT THE BINARY FUNCTION  AND HOW TO OVERLOAD IT .

AND THIS IS ONE IS ALL ABOUT THAT HOW TO OVERLOAD A OPERATOR WITH THE FRIEND FUNCTION AND THIS TIME THE OPERATOR IS THE UNARY OPERATOR (A -> A).

CODE.......................................................................................................................................................

#include<iostream,.h>
#include<conio.h>
class abc
{
              int i ;
              public :
                          void input ( )
                          {
                                                cout<<"\n enter any number :";
                                                cin>>i;
                          }
                          int display ( )
                          {
                                                return i ;
                          }
                          void operator  - ( )
                          {
                                                i = - i ;
                          }
friend void operator (abc&m)
{
                       m.i = - m.i ;
}
} ;
void main ( )
{
                     abc a ;
                     a.input ( ) ;
                     - a ; //a.operator ( )
                     cout<<"a=""<<a.display ( ) ;
                     getch ( ) ;
}

CODE END..............................................................................................................................................

THANKS FOR YOUR TIME TO THIS ARTICLE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

IF YOU HAVE ANY DOUBT REGARDING ANY ARTICLE ON MY WEBSITE THEN WRITE IN THE COMMENT BOX AND FOLLOW US FOE LATEST UPDATES OF THE ARTICLE AND IF YOU WANT IT HELPFUL THEN SHARE IT .
LET'S MEET IN THE NEXT ARTICLES>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>



About hack guru

hack guru
Recommended Posts × +

0 comments:

Post a Comment