Binary Operator Overloading in c++


Program body

#include

#include

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;

}

Made in

it is created in C++ language 

Source

and in codeblocks compiler

Source

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center