Distance time1, time2

Hello everybody! This is my code which distance time1 and time2. But it doesn't work. error message is "Could not find a match for 'time::time()". I don't understand about this error. Please help me!

#include<iostream.h>
#include<conio.h>
enum bool{am, pm};

class date
{
private:
int year;
int month;
int day;

public:
date(int y1, int m1, int d1)
{
year=y1;
month=m1;
day=d1;
}
long Day();
};

long date::Day()
{
long p;
long a[13],i,t=0;

char* b[7];
a[1]=a[3]=a[5]=a[7]=a[8]=a[10]=a[12]=31;
a[4]=a[6]=a[9]=a[11]=30;
a[2]=28;
for(i=1;i<year;i++)
if(i%400==0||(i%4==0&&i%100!=0))
t++;
p=(year-1)*365+t;
if(year%400==0||(year%4==0&&year%100!=0))
a[2]=29;
for(i=1;i<month;i++)
p+=a[i];
p+=day;
return p;
}

class time:public date
{
int hour;
int minute;
int second;

public:
bool bo;
time(int y2,int m2,int d2,int h1, int m1, int s1, bool bo1):
date(y2,m2,d2)
{
hour=h1;
minute=m1;
second=s1;
bo=bo1;
}

long Hour();
int Convert();
time operator-(time);
int rehour()
{
return hour;
}
int reminute()
{
return minute;
}
int resecond()
{
return second;
}
};
long time::Hour()
{
return((Day()-1)*2);
}

int time::Convert()
{
if(bo==pm)
{
hour=hour+12;
return hour;
}
else
return hour;
};

time time::operator-(time t1)
{
time t;
hour=Convert();
hour=Hour()+hour;
t1.hour=t1.Convert();
t1.hour=t1.Hour()+t1.hour;
if(second<t1.second)
{
second+=60;
minute-=1;
}
if(minute<t1.minute)
{
minute+=60;
hour-=1;
}
t.second=second-t1.second;
t.minute=minute-t1.minute;
t.hour=hour-t1.hour;
return t;
};


void main()
{
clrscr();
time time1(2009,11,28,11,5,9,am);
time time2(2009,11,28,10,5,9,am);
time time3;
time3=time1-time2;

cout<<time3.rehour()<<" Hour ";
cout<<time3.reminute()<<" Minute ";
cout<<time3.resecond()<<" Second";

getch();
}
time time3; time doesn't have a constructor which takes no arguments
Topic archived. No new replies allowed.