来自官方文档。。。感谢老王指出需要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. HDU 5178:pairs(二分,lower_bound和upper_bound)

    pairs Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  2. windows下配置redis

    1.首先去GitHub上下载所需文件,这里我们下载的是zip文件 https://github.com/MicrosoftArchive/redis/releases 2.解压后文件目录如下 3.启动 ...

  3. 推荐 Laravel API 项目必须使用的 8 个扩展包

    如今在现代网络开发中,比较流行的模式是基于 API 开发,可以通过手机或网站来创建服务. Laravel 是创建基于 API 的项目的最佳框架之一,它为世界各地的大型社区提供了高速开发. Larave ...

  4. 编辑文章 - 博客频道 - CSDN.NET

    站点连接 :http://www.gaoshou.me/uid/19125624    不用不知道,一用吓一跳. 每一个月的手机话费不用愁了. 仅限苹果手机 1.同步请求能够从因特网请求数据.一旦发送 ...

  5. iview admin 发布到IIS

    公司项目打算做前后端分离,选型最后选了vue+webapi的模式.于是在网上找到了iview及iview admin 这个后台管理模板,里面东西很完善.有这么好的东西,而且MIT协议,项目本身也比较简 ...

  6. 【转】每天一个linux命令(49):at命令

    原文网址:http://www.cnblogs.com/peida/archive/2013/01/05/2846152.html 在windows系统中,windows提供了计划任务这一功能,在控制 ...

  7. .csv 和 .xls 的区别

    .csv 和 .xls 的区别 .csv .xls 较为通用,易导入至各式表格.资料库等 Microsoft excel的专用档案 文本档案,用记事本就可以打开 二进位档案,只有用excel才能打开 ...

  8. mac os 里的 JAVA_HOME

    google了一下,发现了这篇文章Important Java Directories on Mac OS X(https://developer.apple.com/library/content/ ...

  9. git 报错及解决

    报错:fatal: refusing to merge unrelated histories==== 解决办法:git pull加上参数,如:git pull –allow-unrelated-hi ...

  10. JS enter事件及数据不完整阻止下一步操作

    阻止下一步操作: 1.return false;  2.e.preventDefault(); 但IE8不支持 //键盘事件|enter $(function () { document.onkeyd ...