#include
class Date
{
int year,month,day;
public :
void show();
int set(int a,int b,int c);
};
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;
cout<<"s="<<s<<endl;
}
int main()
{
Date date1;
date1.show ();
date1.set (1996,5,13);
return 0;
}
樓主你把cout<<"s="<<s<<endl;放在了return後面當然輸不出結果了
兩句話換個位置就好