博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c++官方文档
阅读量:6184 次
发布时间:2019-06-21

本文共 2903 字,大约阅读时间需要 9 分钟。

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

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
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<
<

  

posted on
2017-12-10 00:44 阅读(
...) 评论(
...)

转载于:https://www.cnblogs.com/shuiyonglewodezzzzz/p/8013971.html

你可能感兴趣的文章
(三)spring cloud微服务分布式云架构-服务网关zuul初级篇
查看>>
Spring Cloud--Honghu Cloud分布式微服务云系统—System系统管理
查看>>
Linux服务器配置——SAMBA
查看>>
我的WP7应用
查看>>
js打开连接 _无需整理
查看>>
我的友情链接
查看>>
C语言结合windowsApi遍历文件
查看>>
linux 系统无法启动的基本解决方法
查看>>
Yii框架学习笔记 [PHP]
查看>>
饿了么MySQL异地多活的数据双向复制经验谈
查看>>
MySQL的btree索引和hash索引的区别
查看>>
计算机基础
查看>>
我的友情链接
查看>>
Hystrix系列-4-Hystrix的动态配置
查看>>
oracle数字函数
查看>>
myeclipse svn 分支
查看>>
ORACLE CHAR,VARCHAR,VARCHAR2,NVARCHAR类型的区别与使用
查看>>
SQL Server AlwaysOn架构及原理
查看>>
spring-session学习
查看>>
PHP中类的使用,面向对象的思路
查看>>