i += 1;
_Myt& operator+=(difference_type _Off)
{ // increment by integer
*(_Mybase *)this += _Off;
return (*this);
}
++i;
_Myt& operator++()
{ // preincrement
++*(_Mybase *)this;
return (*this);
}
i++;
_Myt operator++(int)
{ // postincrement
_Myt _Tmp = *this;
++*this;
return (_Tmp);
}
从以上三者的具体实现可以看出i++返回i而不是i + 1的结果,并且i++过程中会有局部变量的申明初始化和释放,i += 1;和++i,并没有;所以在for循环中,++i的效率比i++更高。