1.<<优先级比表达式中的高
#include<string>
int main(void)
{
using namespace std;
int x;
cout << "The expression x = 100 has the value ";
cout << (x=100) << endl;//如果不加括号会报错,加上括号则显示100
cout << "Now x = " << x << endl;
cout << "The expression x < 3 has the value ";
cout << (x<3) << endl;
cout << "The expression x > 3 has the value ";
cout << (x>3) << endl;
cout.setf(ios_base::boolalpha); //函数调用一个标记,命令cout显示true和false而不是0或1
cout << "The expression x < 3 has the value ";
cout << (x<3) << endl;
cout << "The expression x > 3 has the value ";
cout << (x>3) << endl;
return 0;
}
2.c++所允许的另一种for循环表达式语句
ifor (int i=0; i<5; i++);
3.使用const来表示数组的元素个数
使用方法:
cout 类型名 名城名 = 数字;
const int ArSize = 16;
4.前缀格式和后缀格式没有区别:这两句没有区别
for(n=lim; n>0; --n) 和 for(n=lim; n>0; n--)
5.在语句中申明的变量,在语句结束时,变量也结束。
如果在语句外有一个变量和语句内有一个变量,那执行到语句时,语句中的替换语句外的,当语句结束时,就执行语句外的变量