发现每天都能碰到问题,拜托你们了,又麻烦了
#include <iostream.h>class Tdate
{
public:
void set(int m,int d, int y)
{
month=m; day=d; year=y;
}
bool Isleapyear()
{
if((year%4==0&&year%100!=0)||(year%400==0))
return true;
else
return false;
}
void print()
{
cout<<month<<"/"<<day<<"/"<<year<<endl;
}
private:
int month; int day; int year;
};
void main()
{
Tdate a;
a.set(10,1,1949);
a.print();
if(a.Isleapyear) //这条语句有问题? 不管输入哪年 都是输出这句话。该这么改呢
cout<<"It is a leap year!"<<endl;
else
cout<<"It is not a leap year!"<<endl;
}