//2012 8 31 22:42
//常数据成员的使用
//P87修改
#include
#include
class Date
{
private:
int year,month,day;
public:
Date(int y,int m, int d);
void showDate()const;
};
Date::Date(int y,int m, int d)
{
year=y;
month=m;
day=d;
}
void Date::showDate()const
{
cout< }
void main()
{
const Date d(2011,5,6);
d.showDate();
const Date a(1971,9,26);
a.showDate();
const Date b(1972,4,19);
b.showDate();
}
//常数据成员的使用
//P87修改
#include
#include
class Date
{
private:
int year,month,day;
public:
Date(int y,int m, int d);
void showDate()const;
};
Date::Date(int y,int m, int d)
{
year=y;
month=m;
day=d;
}
void Date::showDate()const
{
cout< }
void main()
{
const Date d(2011,5,6);
d.showDate();
const Date a(1971,9,26);
a.showDate();
const Date b(1972,4,19);
b.showDate();
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27660822/viewspace-742420/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/27660822/viewspace-742420/