Write a program of binary operator overloading


 

/* Write a program of binary operator overloading*/

#include<iostream.h>

#include<conio.h>

class scope

{

public:

int a,b;

scope()

{

a=5;

b=6;

}

scope operator+()

{

scope te;

te.a=te.a+te.b;

return te;

}

};

void main()

{

clrscr();

scope s1,s2,s3;

s3.a=s1.a+s2.b;

cout<<“s3.a=”<<s3.a;

getch();

}

/* output:

s3.a=11*/

Related Posts

Comments are closed.