1 赋值运算符
int i=0,j=0,k=0;
const int ci=i;
2 前置的递增运算符:先算后用,后置的递增运算符:先用后算。递减一样。
3 成员访问运算符
string s1="a string",*p=&s1;
auto n=(*p).size();
n=p->size();
4 iter的类型是vector<string>::iterator,
*iter++; 合法 (*iter)++; 不合法 *iter.empty() 不合法
Iter->empty(); 合法 ++*iter; 不合法 iter++->empty(); 和法
5 在大多数表达式中,比int类型小的整形值提升为较大的整数类型;
在条件中,非布尔值转换布尔类型;
初始化过程中,初始值转换成变量的类型,在赋值语句中,右侧运算对象转换成左侧运算对象的类型;
如果算术运算或关系运算的运算对象有多种类型,需要转换成同一种类型;
6 强制类型转换
int i = 2, j = 1;
double slope = static_cast<double>(j) / i; //静态类型转换
double d = 3.14;
void *p = &d;
double *dp = static_cast<double *>(p);
cout << *dp << endl;
//const_cast只能改变运算对象的底层const
const char *pc = "yu linfeng";
char *p2 = const_cast<char *>(pc);
cout << p2 << endl;
//reinterpret_cast为运算对象的位模式提供较低层次的重新解释
int *ip;
char *pc= reinterpret_cast<char*>(ip);
7 break语句
break语句负责终止离它最近的while, do while, for或switch语句,并从这些语句之后的第一个语句继续执行。
8 continue语句
continue语句终止最近的循环中的当前迭代并立即开始下一次迭代。
9 标准异常
Exception 最常见的问题
Runtime_error 运行时才能检测的问题
Range_error 运行时错误,生成结果超出有意义的值域范围
Overflow_error 运行时错误,计算上溢
Underflow_error 计算下溢
Logic_error 程序逻辑错误
Domain_error 参数对应的结果不存在
Invalid_argument 无效参数
Length_error 长度错误
Out_of_range 使用一个超出有效范围的值