我收到的伪代码:
Date& operator++(){
//add 1 to d //tomorrow, unless we were at the end of the month
//if is_date is false
// //need to change to first of next month
// set d to 1
// if m is December
// //need to change to next year too
// set m to January
// increment y
// else
// increment m
return *this;
}
我的解释:
Date& Date::operator++(){
if (is_date==false){
m=m+1;
d=1;
}
if (m==dec && d==29){
m=jan;
y=y+1;
}
else{
m=m+1;
}
d=d+1;
}
这看起来好吗?我正在根据 Stroustrups 书进行硬件作业。只需要一些验证