您的位置:首页 > 编程语言 > C语言/C++

win编程实践(2)【c++】

2015-11-18 17:14 393 查看
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;}        

本博客所有内容是原创,如果转载请注明来源

http://blog.csdn.net/myhaspl/

 
结果如下:
 
int
int
9 0   5   11  24
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: