标签:
1、 auto让编译器自动确定类型,typeid返回类型,位移操作
源代码如下:
//ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
int main()
{
//auto自动判断类型,typeid函数返回类型
int x = 5000;
int y = 20;
auto z1=x/y;
auto z2=y/x;
char temp;
cout << typeid(z1).name()<< endl;
cout << typeid(z2).name()<< endl;
//位运算
int x1 = 0x0001;
int x2 = 0x0008;
int x3 = 0x0005;
int x4 = 0x000A;
int z3 = x1|x2;//或
int z4 = x1&x2;//与
int z5 = x1|x3;//或
int z6 = x1^x4;//异或
int z7 = x2 >> 2;//右移2位,除2^2
int z8 = z7 << 1;//左移1位,乘2
cout << z3<<" "<<z4<<" "<<z5<<" "<<z6<< " "<<z7<<" "<<z8<<endl;
cin >> temp;
return 0;
}
结果如下:
int
int
9 0 5 11 24
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/myhaspl/article/details/49909991