现代编译器产品会对代码进行优化
优化使得最终的二进制更加高效
优化后的二进制程序丢失了C/C++的原生语义
不可能从编译后的二进制程序还原C/C++程序
++操作符
++操作符可以被重载
全局函数和成员函数均可进行重载
前置++操作符不需要额外的参数
重载++操作符不需要额外的参数
重载后置++操作符需要一个int类型的占位参数
++操作符重载函数:
#include <iostream>
#include <string>
using namespace std;
class Test
{
int mValue;
public:
Test(int i)
{
mValue = i;
}
int value()
{
return mValue;
}
Test& operator ++()
{
++mValue;
return *this;
}
Test operator ++(int)
{
Test ret(mValue);
mValue ++;
return ret;
}
};
int main()
{
Test t(0);
cout<< t.value() <<endl;
Test tt = ++t;
cout<< tt.value() <<endl;
t++;
return 0;
}
输出结果:
0
1
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。