第三章作业3.24
来源:互联网 发布:云计算 电子政务 编辑:程序博客网 时间:2024/06/14 09:44
# include <iostream>
using namespace std;
class Date{
public :
void printDate();
void GetYear();
void GetMonth();
void GetDay();
void SetDate(int y,int m,int d);
private:
int year;
int month;
int day;
};
void Date::printDate()
{
cout<<year<<"."<<month<<"."<<day<<endl;
}
void Date::GetYear()
{
cout<<"该日期年份"<<" "<<year<<endl;
}
void Date::GetMonth()
{
cout<<"该日期月份"<<" "<<month<<endl;
}
void Date::GetDay()
{
cout<<"该日期"<<" "<<day<<endl;
}
void Date::SetDate(int y,int m,int d)
{
year=y;
month=m;
day=d;
}
int main()
{
Date d1,d2,d3;
d1.SetDate(2010,6,8);
d1.printDate();
d1.GetYear();
d1.GetMonth();
d1.GetDay();
cout<<"************"<<endl;
d2.SetDate(2015,4,1);
d2.printDate();
d2.GetYear();
d2.GetMonth();
d2.GetDay();
cout<<"************"<<endl;
d3=d1;
cout<<"复制d1的日期"<<endl;
d3.printDate();
d3.GetYear();
d3.GetMonth();
d3.GetDay();
return 0;
}
using namespace std;
class Date{
public :
void printDate();
void GetYear();
void GetMonth();
void GetDay();
void SetDate(int y,int m,int d);
private:
int year;
int month;
int day;
};
void Date::printDate()
{
cout<<year<<"."<<month<<"."<<day<<endl;
}
void Date::GetYear()
{
cout<<"该日期年份"<<" "<<year<<endl;
}
void Date::GetMonth()
{
cout<<"该日期月份"<<" "<<month<<endl;
}
void Date::GetDay()
{
cout<<"该日期"<<" "<<day<<endl;
}
void Date::SetDate(int y,int m,int d)
{
year=y;
month=m;
day=d;
}
int main()
{
Date d1,d2,d3;
d1.SetDate(2010,6,8);
d1.printDate();
d1.GetYear();
d1.GetMonth();
d1.GetDay();
cout<<"************"<<endl;
d2.SetDate(2015,4,1);
d2.printDate();
d2.GetYear();
d2.GetMonth();
d2.GetDay();
cout<<"************"<<endl;
d3=d1;
cout<<"复制d1的日期"<<endl;
d3.printDate();
d3.GetYear();
d3.GetMonth();
d3.GetDay();
return 0;
}
0 0
- 第三章作业3.24
- 第三章作业3.24
- 第三章作业 3.24
- 第三章作业3.24
- C++作业2第三章3.22-3.24
- 第三单元3.24作业
- 第三章作业
- 第三章作业
- CCNA第三章作业
- 第三章实验作业
- 第三章作业
- 第三章作业
- 第三章作业
- 第三章作业
- 第三章作业
- 第三章作业
- 第三章作业
- 第三章作业
- 触发didSelectRowAtIndexPath事件
- android自定义view需要注意的地方
- 伍颖妍
- (*leetcode_位运算)Reverse Bits
- mahout探索之旅——CART分类回归算法
- 第三章作业3.24
- 整数划分,输出
- 摆动序列
- C指针小结2
- myeclipse中配置JRE配置 Tomcat7.0、JDK1.6、Myeclipse6.5开发环境配置
- [python]归并排序
- struts2,跨package重定向
- leetcode reverse words in a string
- 淘宝实习数据分析师题目【2015.03.31】