【发布时间】:2013-12-15 21:00:35
【问题描述】:
我有我老师制作的程序中的这些行代码:
TimeKeeper& operator++() {
d_seconds++;
return *this;
}
const TimeKeeper operator++(int) {
TimeKeeper tk(*this);
++(*this);
return tk;
}
我的老师问我们的一个问题是“operator++() 返回一个引用,operator++(int) 返回一个值,解释一下为什么?”
谁能给我解释一下? 如果你需要其余的代码,我不介意把它放上去! 谢谢!!
【问题讨论】: