Win Programming Practice (2) "C + +"

Source: Internet
Author: User

1, auto Let the compiler determine the type automatically, typeID return type, displacement operation

The source code is as follows:

//consoleapplication1.cpp: defines the entry point for the console application.

//

#include "StdAfx.h"

#include <iostream>

using std::cout;

using Std::endl;

using std::cin;

int Main ()

{

//auto automatic judgment type, typeid function return type

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;

// bit arithmetic

int x1 = 0x0001;

int x2 = 0x0008;

int x3 = 0x0005;

int x4 = 0x000A;

int z3 = x1|x2; // or

int z4 = x1&x2; // with the

int z5 = x1|x3; // or

int Z6 = x1^x4; // XOR or

int Z7 = x2 >> 2; // Move right 2 bits, except 2^2

int Z8 = Z7 << 1; // Move left 1 bits, multiply by 2

cout << z3<<"<<Z4<<"<< Z5<<"<<z6<< " "<<Z7 << " " <<Z8<<Endl;

CIN >> temp;

return 0;

}

This blog all content is original, if reprint please indicate source http://blog.csdn.net/myhaspl/

The results are as follows:

Int

Int

9 0 5) 11 24

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Win Programming Practice (2) "C + +"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.