来自官方文档。。。感谢老王指出需要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. 20155229 2016-2017-2 《Java程序设计》第六周学习总结

    20155229 2016-2017-2 <Java程序设计>第六周学习总结 教材学习内容总结 第十章 Java中,输入串流代表对象为java.io.InputStream,输出串流代表对 ...

  2. HDU 2009

    求数列的和 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submiss ...

  3. Spring学习--静态工厂方法、实例工厂方法创建 Bean

    通过调用静态工厂方法创建 bean: 调用静态工厂方法创建 bean 是将对象创建的过程封装到静态方法中 , 当客户端需要对象时 , 只需要简单地调用静态方法 , 而不需要关心创建对象的细节. 要声明 ...

  4. JQuery禁止回车提交表单

    //禁止回车键提交表单——动态绑定 $(function(){ $("input").on('keypress',  //所有input标签回车无效,当然,可以根据需求自定义 fu ...

  5. seleniumWebdriver浏览器驱动信息汇总

    selenium是thoughtworks公司开发的一款开源的测试工具,主要用来做web端的自动化测试. Python安装selenium,直接使用执行pip install selenium(pyt ...

  6. 整理开源协议问题 GPL APACHE

    整理开源协议问题 GPL APACHE APACHE 和 GPL 互相不兼容. APACHE 不可以使用 GPL 的代码. 但是 APACHE 可以调用 GPL 组件的接口. 比如 Linux 和 A ...

  7. [转]Spring事务<tx:annotation-driven/>

    在使用SpringMVC的时候,配置文件中我们经常看到 annotation-driven 这样的注解,其含义就是支持注解,一般根据前缀 tx.mvc 等也能很直白的理解出来分别的作用.<tx: ...

  8. maven 知识点2

    maven 命令: table th:first-of-type { width: 500px; } table th:nth-of-type(2) { } 命令 含义 mvn help:effect ...

  9. js搞定网页的简繁转换

    对网页进行简繁字体转换的方法一般有两种:一是使用<简繁通>这样的专业软件,另外一种是制作两套版本的网页.显然,这两种方法都较为麻烦,而且专业软件一般不能用于免费的空间.笔者在这里给大家提供 ...

  10. ORM练习项目-图书管理系统(BMS)实现细节

    分析 一本书 可以由多个作者编著 一本书只能由一个出版社出版 一个作者可以写多本书 每个作者有自己的简介 对应关系: Author-Book # 多对多 Publish-Book # 一对多 Auth ...