++i 和 i++的实现
生活随笔
收集整理的這篇文章主要介紹了
++i 和 i++的实现
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
++i 和 i++的實現
- 1. ++i 實現:
- 2. i++ 實現:
1. ++i 實現:
int& int::operator++() { *this +=1; return *this; }2. i++ 實現:
const int int::operator(int) { int oldValue = *this; ++(*this); return oldValue; }總結
以上是生活随笔為你收集整理的++i 和 i++的实现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: STL的pair键值对
- 下一篇: 电竞行业有哪些需求 个别需求分析