C++ Primer 笔记三(表达式)

来源:互联网 发布:multisim仿真软件开关 编辑:程序博客网 时间:2024/06/16 21:15
  • for 循环
statement1
for (int_expr; test_expr; update_expr)
    statement2
statement3
执行顺序:inter_expt->test_expr->statement2->update_expr

c++11
double prices[5]={1.23, 10.26,6.13}
for (double x: prices)  //遍历
    cout << x <<endl;
for (double &x: prices)//修改值
    x = x * 0.8;   
for (int x: {3,5,2,8,6})
    cout << x << endl;

逗号运算符:cata=17,240 -->(cat=17),240 --> cata=17   ,240不起作用
                      cata=(17,240) --> cata=240 ,17不起作用

cin 有缓冲区,忽略空格和换行符,只有按下回车键后消息才会被发送;可以使用cin.get(ch)获取

如果逻辑表达式and的左侧为false,则C++不会去判断右表达式

extern
static
const
auto
register
mutable
定位new


0 0