c++常量定义支持两种语法。
#define 常量名称 常量值
const 常量类型 常量名称 = 常量值
例如我们分别用两种语法表示linux和windows的换行符
#include <iostream>
#define WIN_EOL "\r\n";
using namespace std;
const char LIN_EOL = '\n';
int main()
{
std::cout << "Hi Windows" << WIN_EOL;
std::cout << "Hi Linux" << LIN_EOL;
return 0;
}注意:常量定义为大写字母形式是一种编程代码规范