I am using borland turbo C++ complier (4.5). This is my code but i am getting error as follows: Multiple declaration for 'time::add(time)'.Here i am juss overloading the add() three times the error comes in the 3rd overload i.e in "void add(time t1)".
#include<iostream.h>
#include<conio.h>
class time
{
int h,m;
public:
void input()
{
cout<<"\n Enter hour :";
cin>>h;
cout<<"\n Enter min :";
cin>>m;
}
void display()
{
cout<<"\n time is : "<<h<<":"<<m;
}
void add(time t1,time t2)
{
h=t1.h+t2.h+(t1.m+t2.m)/60;
m=(t1.m+t2.m)%60;
}
time add(time t1)
{
time t3;
t3.h=h+t1.h+(m+t1.m)/60;
t3.m=(m+t3.m)%60;
return t3;
}
void add(time t1)
{
h=h+t1.h+(m+t1.m)/60;
m=(m+t1.m)%60;
}
};
int main()
{
time t1,t2,t3;
t1.input();
t2.input();
t3.add(t1,t2);
t3.display();
t3=t2.add(t1);
t3.display();
t2.add(t1);
t2.display();
return 0;
}