有一道面试题:(http://blog.csdn.net/hackbuteer1/article/details/7467139)
int a=5,则 ++(a++)的值是()
A、5 B、 6 C、7 D、逻辑错误
这个看一下前自增和后自增的定义就明白了:
//++a
int &int::operator++()
{
*this+=1;
return *this;
}
//a++
const int int::operator++(int)
{
int oldvalue=*this;
++(*this);
return oldvalue;
}