1

```
/*i want to overloaded operator in my program. but i dnt know how to add overloaded + operator in this prgram. plzzzzzzzzz help me to solve this problem*/
#include<iostream.h>
class rational{
private :
int numerator, dnomenator ;
void reduction();
public :
rational () //default contructer
{
numerator=dnomenator=1;
}
rational (int num, int dnum) //parameterised constructer
{
numerator=num;dnomenator=dnum;
reduction();
}
void show();
rational operator +();
};
rational rational ::operator +(){
rational sum;
sum=numerator+dnomenator;
return sum;
}
void rational ::show(){
cout<<numerator<<"/"<<dnomenator<<endl;
}
void rational::reduction()//reduces the fraction
{
int largest;
largest = numerator > dnomenator ? numerator : dnomenator;
/*if(numerator>dnomenator)
{
largest=dnomenator;
}
else
{
largest=numerator;
}*/
int gcd = 0; // greatest common divisor
for ( int count= 2; count <= largest; count++ )
if ( numerator % count == 0 && dnomenator % count == 0 )
gcd = count;
if (gcd != 0)
{
numerator /= gcd;
dnomenator /= gcd;
}
}
int main()
{
rational r;
rational c(4,6);
c.show();
return 0;
}
```