问题描述
- 求两个日期相差的天数 用友元函数 我不知道要怎么改 看不懂调试。
- #include
class Date
{
int yearmonthday;
public :
void show();
int set(int aint bint c);
friend int End(Date &d1 Date &d2);
};
void Date::show ()
{
cout<<""please input year monthday.""<}
int Date::set (int aint bint c)
{
year=a; month=b; day=c;
int s=0 ij=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 d1d2;
d1.show ();
d1.set (1996513);
d2.show ();
d2.set (2016410);
End(d1d2);
return 0;}
2296: '-' : illegal left operand has type 'int (__thiscall Date::*)(intintint)'
C:作业gogoone.cpp(41) : error C2297: '-' : illegal right operand has type 'int (__thiscall Date::*)(intintint)'
执行 cl.exe 时出错.
解决方案
d1.set-d2.set?
set是个成员函数啊……
解决方案二:
http://www.cnblogs.com/xiangxiaodong/archive/2012/02/14/2351883.html
时间: 2024-10-24 01:27:37