来自官方文档。。。感谢老王指出需要c++11,一下代码全在c++11下编译,编译参数加入  -std=c++11

#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<memory.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <climits>
#include <sstream>
using namespace std; int main(const int argc, char** argv)
{
//c style
int i = 0;
//c++ style
int j(1);
//only in c++ 11
int k = { 2 };
cout << i << endl;
cout << j + k << endl;
int foo = 0;
//same as int bar=foo;
auto bar = foo;
cout << bar << endl;
//bar2 type is int,has no initVal
decltype(foo) bar2;
bar2 = 4.2000;
cout << bar2 << endl;
cout << sizeof(wchar_t) << endl;
//base 10
int ii = 10;
//base 8
int kk = 010;
//base 16
int kkk = 0xff;
cout << ii << " " << kk << " " << kkk << endl;
int kkkk = 75; //int
unsigned int uik = 4294967295u; //unsigned int
long lk = 75l; //long
long ulk = 75ul; //unsigned long
cout << kkkk << " " << uik << " " << lk << " " << ulk << endl;
cout << "long double size " << sizeof(long double) << endl;
cout << "long long int size " << sizeof(long long int) << endl;
//default type for floating-point literals is double
//we can add suffix f or l
float fi = 6.02e23f; //float
long double ld = 3.14159L; //long double
cout << "fi " << fi << " long double " << ld << endl;
//Internally, computers represent characters as numerical codes
//计算机本质上将字符表示成数字
string x = "string expressed in \
two lines";
cout << x << endl;
//All the character literals and string literals described above are made of characters of type char
//所有字符和字符串字面量都是由char组成,可以加下面的前缀
//u char16_t
//U char32_t
//L wchar_t
//string字面量可以加以下前缀
//u8 The string literal is encoded in the executable using UTF-8
//执行时用utf-8编码
//R The string literal is a raw string
//表示原始的string
string ss = R"(string with \backslash)";
string sss = "(string with \backslash)";
cout << ss << endl;
cout << sss << endl;
//c++已经存在三个字面量 true false nullptr
cout << "bool" << sizeof(bool) << " sizeof nullptr" << sizeof(nullptr)
<< endl;
bool footrue = true;
bool foofalse = false;
int* p = nullptr;
cout << footrue << endl;
cout << foofalse << endl;
//&p p的地址
//*p p指向内存的内容
//p p这块内存中的值
cout << p << endl;
cout << "&p " << &p << endl;
int** pp = &p;
cout << pp << endl;
//有魔力的语法
//根据文档的描述 c++内置三个字面量 true,false nullptr
cout << (false == nullptr) << endl;
//显示转换
int ci;
float cf = 3.14;
//继承自 c
ci = (int) cf;
//c++ style
ci = int(cf);
//The value returned by sizeof is a compile-time constant, so it is always determined before program execution.
//sizeof返回编译时的常量,所以这个值永远都在执行前确定
string mystr("123465 456 79");
int myint;
//标准头文件sstream定义了一种叫做stringstream的类型,允许把string作为输入流
stringstream sin(mystr);
//流已经到末尾
string mystr2;
while (sin >> myint)
cout << myint << " ";
cout << endl;
getline(stringstream(mystr), mystr2);
cout<<mystr2<<endl;
return 0;
}

  

c++官方文档的更多相关文章

  1. 【AutoMapper官方文档】DTO与Domin Model相互转换(上)

    写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...

  2. 2DToolkit官方文档中文版打地鼠教程(三):Sprite Collections 精灵集合

    这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...

  3. 2DToolkit官方文档中文版打地鼠教程(二):设置摄像机

    这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...

  4. 2DToolkit官方文档中文版打地鼠教程(一):初始设置

    这是2DToolkit官方文档中 Whack a Mole 打地鼠教程的译文,为了减少文中过多重复操作的翻译,以及一些无必要的句子,这里我假设你有Unity的基础知识(例如了解如何新建Sprite等) ...

  5. 【AutoMapper官方文档】DTO与Domin Model相互转换(中)

    写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...

  6. 【AutoMapper官方文档】DTO与Domin Model相互转换(下)

    写在前面 AutoMapper目录: [AutoMapper官方文档]DTO与Domin Model相互转换(上) [AutoMapper官方文档]DTO与Domin Model相互转换(中) [Au ...

  7. Ionic2系列——Ionic 2 Guide 官方文档中文版

    最近一直没更新博客,业余时间都在翻译Ionic2的文档.之前本来是想写一个入门,后来觉得干脆把官方文档翻译一下算了,因为官方文档就是最好的入门教程.后来越翻译越觉得这个事情确实比较费精力,不知道什么时 ...

  8. Kotlin开发语言文档(官方文档)-- 目录

    开始阅读Kotlin官方文档.先上文档目录.有些内容还未阅读,有些目录标目翻译还需琢磨琢磨.后续再将具体内容的链接逐步加上. 文档链接:https://kotlinlang.org/docs/kotl ...

  9. 一起学微软Power BI系列-官方文档-入门指南(1)Power BI初步介绍

    我们在前一篇文章微软新神器-Power BI,一个简单易用,还用得起的BI产品中,我们初步介绍了Power BI的基本知识.由于Power BI是去年开始微软新发布的一个产品,虽然已经可以企业级应用, ...

  10. 一起学微软Power BI系列-官方文档-入门指南(2)获取源数据

    我们在文章: 一起学微软Power BI系列-官方文档-入门指南(1)Power BI初步介绍中,我们介绍了官方入门文档的第一章.今天继续给大家介绍官方文档中,如何获取数据源的相关内容.虽然是英文,但 ...

随机推荐

  1. AngularJS的简单订阅发布模式例子

    控制器之间的交互方式广播 broadcast, 发射 emit 事件 类似于 js中的事件 , 可以自己定义事件 向上传递直到 document 在AngularJs中 向上传递直到 rootScop ...

  2. 杭电oj2001-C语言

    题目 题目 Problem Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离. Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x ...

  3. hiho1622 有趣的子区间(YY)

    题目链接:http://hihocoder.com/problemset/problem/1622?sid=1230113 #1622 : 有趣的子区间 时间限制:10000ms 单点时限:1000m ...

  4. Pma模块详解,对用户登录linux等进行限制,密码修改限制等

    PAM详细介绍 2014-04-02 09:26:41 标签:PAM 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://lidefu ...

  5. MySQL Disk--SSD与RAID

    ===================================================SSD与RAID 51.在RAID 5这类Parity-RAID上存在partial-stripe ...

  6. Zxing图片拉伸解决 Android 二维码扫描

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/aaawqqq/article/details/24852915  二维码扫描  Android Zx ...

  7. spring 核心思想:AOP 理解

    什么是AOP? AOP概念介绍 所谓AOP,即Aspect orientied program,就是面向方面(切面)的编程. 面向切面编程Aspect-Orlented-Programming,即AO ...

  8. mysql explicit_defaults_for_timestamp参数

    在mysql中:- timestamp列如果没有显式定义为null,默认会被设置为not null属性.(其它的数据类型如果没有显式定义为not null,默认是可以为null的).设置timesta ...

  9. 【python】专用下划线标识符说明

    __xxx__:系统定义名字 __xxx:类中私有变量名 说明:__xxx看做“私有的”,在模块或者类外是不可以使用.

  10. ASM配置管理

    http://blog.chinaunix.net/uid-22646981-id-3060280.htmlhttp://blog.sina.com.cn/s/blog_6a5aa0300102uys ...