可能重复:
使用16位整数的重要性
如果今天的处理器执行(在标准条件下)32位操作 - 那么使用"短整数"是否合理?因为为了对该数据执行操作,它会将其转换为32位(从16位)整数,执行操作,然后返回到16位 - 我想.那有什么意义呢?
本质上我的问题如下:
为了引入类似C#/ Java的语法,通过预处理命令重新定义C++访问修饰符可能会产生什么影响呢?
#include <iostream>
// The access modifiers are redefined here.
#define public public:
#define protected protected:
#define private private:
class Halo
{
public Halo(int xx)
{
x = xx;
}
public int getX()
{
return x;
}
private int x;
};
int main()
{
Halo* halo = new Halo(3);
std::cout << halo->getX();
return 0;
}
Run Code Online (Sandbox Code Playgroud)