Class date

This is my code(distance date 1&date2). I don't understand well using class and operator. So please help me!

#include<iostream.h>
#include<conio.h>

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

public:
date(int year1, int month1, int day1)
{
year=year1;
month=month1;
day=day1;
}
long Day();
long operator-(long);
};

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;
}

long date::operator-(long d1)
{
int d2;
d2=d2-d1.Day();
return d2;
}

main()
{
date d3,
d1(1990,4,11),
d2(1990,4,27);
d3=d2-d1;
}






Thanks screw! I couldn't find the information about this!
Topic archived. No new replies allowed.