zoukankan      html  css  js  c++  java
  • 修饰符的位置

    修饰符的位置

    修饰符 * 和 & 应该靠近数据类型还是该靠近变量名,是个有争议的活题。

    若将修饰符 * 靠近数据类型,例如:int* x; 从语义上讲此写法比较直观,即 x 是 int 类型的指针。

    上述写法的弊端是容易引起误解,例如:int* x, y; 此处 y 容易被误解为指针变 量。虽然将 x 和 y 分行定义可以避免误解,但并不是人人都愿意这样做。

     1 #include <iostream>
     2 
     3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
     4 using namespace std;
     5 int main(int argc, char** argv) {
     6      //按位与运算
     7     cout<<"24&12="<<(24&12)<<endl;
     8     //按位异或运算
     9     cout<<"24^12="<<(24^12)<<endl;
    10     //按位或运算
    11     cout<<"24|12="<<(24|12)<<endl;
    12     //按位取反运算
    13     cout<<"~24="<<(~24)<<endl;
    14 
    15     //左移位运算
    16     cout<<"5<<3="<<(5<<3)<<endl;
    17     cout<<"-5<<3="<<(-5<<3)<<endl;
    18 
    19     //右移位运算
    20     cout<<"5>>3="<<(5>>3)<<endl;
    21     cout<<"-5>>3="<<(-5>>3)<<endl;
    22     return 0;
    23 }
  • 相关阅读:
    Session Cookie介绍和使用
    Java 设计模式(概述)
    Java-JSON 解析
    Java Fileupload
    docker执行mysql容器修改用户权限
    分布式事务Seata
    idea配置git_2
    idea配置注释
    idea配置git的ssh
    远程阿里云镜像问题
  • 原文地址:https://www.cnblogs.com/borter/p/9406128.html
Copyright © 2011-2022 走看看