学习目标:
处理类型
学习内容:
1.类型别名
2.auto类型说明符
3.declutype类型指示符
题目解析
2.33
合法
合法
合法
非法
非法
非法
2.34
2.35
const int i = 42;
auto j = i; //j是int型;
const auto &k = i; //k是int型常量引用
auto *p = &i; //p是int指针
const auto j2 = i, &k2 = i; //j2是int型常量,k2是int型常量引用
2.36
int a = 3, b = 4;
decltype(a) c = a;
decltype((b)) d = a;
++c;
++d;
int a = 4;
int b = 4;
int c = 4;
int &d = 4;
2.37
int a = 3, b = 4;
decltype(a) c = a;
decltype(a = b) d = a;
int a = 3;
int b = 4;
int c = 3;
int &d = 3;
2.38
auto单纯返回指定对象的类型
decltype 用的表达式是变量,则返回顶层const和引用