首页 > 编程语言 >C++中的Type Alias

C++中的Type Alias

时间:2022-11-24 16:25:34浏览次数:35  
标签:uint64 typedef alias rank Alias points C++ Type uint32

在C++中,我们通常使用typedef来实现type alias. 比如:

#include <cstdint>  //C standard int

typedef uint32_t points_t;  //points_t is alias of uint32_t
typedef uint64_t rank_t;  //rank_t is alias of uint64_t

struct score {

  points_t p {};
  rank_t r {};


}

 现在更modern的方式是, 是 using 来进行type alias, 请看:

#include <cstdint>  //C standard int

using points_t = uint32_t;  //points_t is alias of uint32_t
using rank_t = uint64_t;  //rank_t is alias of uint64_t

struct score {

  points_t p {};
  rank_t r {};


}

 

标签:uint64,typedef,alias,rank,Alias,points,C++,Type,uint32
From: https://www.cnblogs.com/wphl-27/p/16922236.html

相关文章