来自官方文档。。。感谢老王指出需要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. Unity3D-常用小功能详解,例子(得分变动效果、倒计时)

    Unity3D-Demo多个功能方法 本文提供全流程,中文翻译.Chinar坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) 1 Score Ind ...

  2. BZOJ4710: [Jsoi2011]分特产【组合数学+容斥】

    Description JYY 带队参加了若干场ACM/ICPC 比赛,带回了许多土特产,要分给实验室的同学们. JYY 想知道,把这些特产分给N 个同学,一共有多少种不同的分法?当然,JYY 不希望 ...

  3. 《Entity Framework 6 Recipes》中文翻译 ---- 系列教程

    为了方便大家的阅读和学习,也是响应网友的建议,在这里为这个系列做一个目录.在目录开始这前,我先来回答之前遇到的几个问题. 1.为什么要学习EF? 这个问题很简单,项目需要.这不像学校,没人强迫你学习! ...

  4. nnlog模块使用

    安利一个好用的写日志模块,python自带的logging模块理解起来比较费劲,直接pip install nnlog即可 使用例子如下代码:   1 2 3 4 5 6 7 8 9 10 11 12 ...

  5. Java使用Unsafe接口操作数组Demo

    public class unSafeArrayDemo { private static final sun.misc.Unsafe UNSAFE; private static final lon ...

  6. 使用 extract-text-webpack-plugin 报错:Error: Chunk.entry was removed. Use hasRuntime()

    问题:使用 extract-text-webpack-plugin 报错:Error: Chunk.entry was removed. Use hasRuntime() 解决:先运行npm unin ...

  7. commons-logging log4j logback 知识点

    log4j 2,需要导入2个jar包: log4j-core-xx.jar log4j-api-xx.jar log4j 2 的 properties 配置文件名字为: log4j2.properti ...

  8. idea引入svn

    刚想在idea看一个svn的项目代码,结果发现导入项目后,idea在右下角弹出了Event Log窗口,里面的红色小字 Can't use Subversion command line client ...

  9. hello word 应用程序的编写

    1.各类文件的书写 src中的文件: hello文件夹中的Makefile文件 # # Copyright (C) - OpenWrt.org # # This is free software, l ...

  10. bat文件:启动,休眠VBox虚拟机

    1. start.Xp_Mysql.bat @echo cd D:\Program Files\VirtualBox\ D: .\VBoxManage startvm Xp_Mysql --type ...