请教两道拿不准的题目,斑竹和朋友快来帮帮忙,谢谢先!
1。Staff类含有int型数据成员ID,两个Staff对象相等是指它们的ID相同。下面的函数重载了运算符==,它用来判断两个Staff对象是否相等,相等时返回true,否则返回false。请将横线处缺失部分补充完整。
bool Staff::Staff==(const Staff &s)
{
returen( 【】 )
}
2。在下面程序的横线处填上适当的内容,使程序执行后的输出结果果为1/2005。
#include<iostream>
using namespace std;
class Date
{
public:
Date(int m=1,int y=0):month(m),year(y){}
void Print(){cout<<month<<"/"<<year<<endl;}
【1】 operator+(const Date&d1.const Date& d2);
private:
int month, year;
};
【2】 operator+(const Date&d1,const Date &d2)
{
int year,month;
year=d1.year+d2.year;
month=d1.month+d2.month;
year+=(month-1)/12;
month=(month-1)%12+1;
return Date(month,year);
}
void main()
{
Date d1(3,2004),d2,d3(10);
d2=d3+d1;
d2.Print();
}