📄 macrosideeffects.cpp
字号:
//: C09:MacroSideEffects.cpp
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
#include "../require.h"
#include <iostream>
using namespace std;
//宏在C中有许多不安全的地方。如在此处经过C 预处理宏扩展之后,
//a++计算两次
//结果不是预期的。
#define BAND(x) (((x)>5 && (x)<10) ? (x) : 0)
void main() {
// ofstream out("macro.out");
// assure(out, "macro.out");
for(int i = 4; i < 11; i++) {
int a = i;
cout << "a = " << a << endl << '\t';
cout << "BAND(++a)=" << BAND(++a) << endl;
cout << "\t a = " << a << endl;
}
} ///:~
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -