#include
class Date
{
int year,month,day;
public :
void show();
int set(int a,int b,int c);
friend int End(Date &d1, Date &d2);
};
void Date::show ()
{
cout<<"please input year ,month,day."<
}
int Date::set (int a,int b,int c)
{
year=a; month=b; day=c;
int s=0, i,j=1;
for(i=0;i
{
if(i%4==0||i%400==0)
j++;
}
s=31*b;
if (b>1)
s=s-3;
if (b>3)
s=s-1;
if (b>5)
s=s-1;
if (b>8)
s=s-1;
if(b>10)
s=s-1;
s=i*365+j+s+c ;
return s;
}
int End(Date &d1, Date &d2)
{
cout<<"相差天数"<<d1.set-d2.set <<endl;
}
int main()
{
Date d1,d2;
d1.show ();
d1.set (1996,5,13);
d2.show ();
d2.set (2016,4,10);
End(d1,d2);
return 0;
}
2296: '-' : illegal, left operand has type 'int (__thiscall Date::*)(int,int,int)'
C:\作业\gogo\one.cpp(41) : error C2297: '-' : illegal, right operand has type 'int (__thiscall Date::*)(int,int,int)'
执行 cl.exe 时出错.