类型别名

类型别名——类型别名指的是某种类型的同义词,通常使用typedef声明,C++11新增了using方式

  例如:typedef int num;

     using num = int;

  以上两种方式均可,注意不要轻易将别名与原来类型表达式等价理解。对于指针类型有如下情况:

     using p = int*;

     const p a = nullptr;  // 将此定义与 const int* b = nullptr; 等价是错误的,a 是指向 int 的常量指针,而b是指向 const int 的指针

posted @ 2023-02-14 17:39  Meetalone  阅读(14)  评论(0编辑  收藏  举报