当前位置:网站首页>++Implementation of I and i++

++Implementation of I and i++

2022-07-06 10:39:00 it_ xiangqiang



++i and i++ The implementation of the


1. ++i Realization :

       
int& int::operator++()
{
*this +=1;
return *this;
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

2. i++ Realization :

       
const int int::operator(int)
{
int oldValue = *this;
++(*this);
return oldValue;
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.



原网站

版权声明
本文为[it_ xiangqiang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131657122856.html