1. Type Alias(类型别名)and Template Alias(模板别名)
在C++11
中,我们不仅可以为类型定义别名,还可以对模板进行定义别名。
别名声明的语法
1. using identifier = type-id //identifier为引入的类型名,type-id为抽象声明器或者任何合法的type-id
2. template <template-parameter-list>
using identifier =type type-id
类型别名声明和typedef
的声明没有差别。
举例
#include <string>
#include <iostream>
#include <type_traits>
class Base{
};
//类型别名
using A = Base;
//等同于 typedef Base A;
A *a = new A(4