标签:style blog http color 使用 os
1.转义字符
一般有两种方式:
\x后紧跟1个或多个十六进制数字、或\后紧跟1、2、3个八进制数字,当中数字部分是字符相应的数值。
#include <iostream>
using namespace std;
int main()
{
bool b = 10;
bool b1 = true;
bool b2 = false;
cout << b << endl;
cout << b1 << endl;
cout << b2 << endl;
cout << "\115" << endl;// M
cout << "\x5B" << endl;// [
cout << "\x21" << endl;// !
return 0;
}
string s1;
string s2(s1);
string s2 = s1;
string s3("value");//s3是字面值副本除空格
string s3 = "value";
string s4(n, 'c');//s4为n个c组成的串string s2 = s1 + ","; //正确 string s2 = "hello" + ","; //错误
vector<int> ivec; vector<Person> person; vector<vector<string>> file;
vector<int> ivec; vector<int> ivec2(ivec); vector<int> ivec3 = ivec; vector<string> svec(ivec);//错误 类型不同
vector<int> v1(10);//v1有10个元素,都是0
vector<int> v2{10};//v2有1个元素,为10
vector<int> v1(10,1);//v1有10个元素,都是1
vector<int> v2{10,1};//v2有2个元素,为10与1
C++ Primer笔记1_转义字符_标准库类型string_标准库类型vector,布布扣,bubuko.com
C++ Primer笔记1_转义字符_标准库类型string_标准库类型vector
标签:style blog http color 使用 os
原文地址:http://www.cnblogs.com/mfrbuaa/p/3825192.html