Feb 26, 2017 at 5:35am UTC
# include <iostream.h>
# include <conio.h>
class distance
{
int feet,inches;
public :
void distance_assign(int f, int i)
{
feet = f;
inches = i;
}
void display()
{
cout << “\nFeet : “ << feet
<< “\tInches : “ << inches;
}
distance operator+(distance d2)
{
distance d3;
d3.feet = feet + d2.feet;
d3.inches = (inches + d2.inches) % 12;
d3.feet += (inches + d2.inches)/12;
return d3;
}
};
void main()
{
clrscr();
distance dist_1,dist_2;
dist_1.distance_assign(12,11)
dist_2.distance_assign(24,1);
distance dist_3 = dist_1 + dist_2;
dist_1.display();
dist_2.display();
dist_3.display();
getch();
}
Questions.
1. What types of operands are used for the overloaded operator?
2. Write out the statement that invokes the overloaded member
function.
Feb 26, 2017 at 5:51am UTC
Dear Hengry
Already I posted. But no one not reply. So Again I post this question. Kindly tell the two questions only.
Feb 26, 2017 at 7:04am UTC
Hi integralfx
What types of operands are used for the overloaded operator?
distance is correct or not ?
Feb 26, 2017 at 7:13am UTC
Hi integralfx
Thanks for your valuable help...