//ex6_6.cpp
#include <iostream>
#include "date.h"
using namespace std;
Date fun(Date d);
int main()
{
Date date1(2000,1,1),date2(0,0,0);
Date date3(date1);
date2=fun(date3);
cout<<"date1:";
date1.Print();
cout<<"date2:";
date2.Print();
cout<<"date3:";
date3.Print();
return 0;
}
Date fun(Date d)
{
Date temp;
temp=d;
return temp;
}
-----------------------------------------------------
class Date
{
public:
Date(int y, int m, int d);
Date(int y=2000):year(y)
{
month=10;
day=1;
cout <<"Constructor of Date with 1 parameter." <<endl;
}
int IsLeapYear();
void Print(){ cout<<year<<"."<<month<<"."<<day<<endl; }
private:
int year,month,day;
};
Date::Date(int y,int m,int d):year(y),month(m),day(d)
{
cout <<"Constructor of Date with 3 parameters."<<endl;
}
int Date::IsLeapYear()
{
return(year%4==0 && year%100 !=0) || (year%400==0);
}
--
FROM 111.197.69.*