Binary operator overloading.

in programming •  7 years ago 

Program Body:

#include <iostream>
#include <string>
using namespace std;
class ester{
int a,b;
public:
    ester(){
    a=0;
    b=0;
    }
    ester(int x,int y){
    a=x;
    b=y;
    }
    ester operator+(ester s){
    ester clows;
    clows.a=a+s.a;
    clows.b=b+s.b;
    return clows;
    }
    void show(){
    cout<<"value of a is "<<a<<endl;
    cout<<"value of b is "<<b<<endl;
    }
};
int main (){
ester erf1(10,30),erf2(20,40),erf3;
erf3=erf1+erf2;
cout<<endl;
erf3.show();
return 0;
}

Thanks

.              .

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

great coding i got knowledge meri post pa bi a jana

Congratulations @learnandgrow! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of posts published
Award for the number of comments

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

This post has received a 3.16 % upvote from @boomerang thanks to: @learnandgrow

@boomerang distributes 100% of the SBD and up to 80% of the Curation Rewards to STEEM POWER Delegators. If you want to bid for votes or want to delegate SP please read the @boomerang whitepaper.

This post has received gratitude of 0.71 % from @appreciator thanks to: @learnandgrow.