int x = 0,y = 1;
typedef decltype(x+y) xytype;
xytype xpy = x + y;
代码参考自《C++ Primer Plus(第6版)》
1)decltype:推断x+y的类型,这个地方是int;
2)typedef:把decltype(x+y)起个别名为xytype,即xytype表示int;
3)可以像int那样使用xytype。
int x = 0,y = 1;
typedef decltype(x+y) xytype;
xytype xpy = x + y;
代码参考自《C++ Primer Plus(第6版)》