65,208
社区成员
发帖
与我相关
我的任务
分享
string s;
typedef string *pstring;
const pstring cstr1=&s;
string s;
typedef string *pstring;
pstring const cstr2=&s;
typedef const_ptr_type const thrd_cons_ptr_const_type; // 第三方式的常量指针常量typedef string RawType; //某个原始数据类型 ,这里是 string,为原始数据类型定义别名RawType
typedef RawType elem_type; //为原始数据类型定义别名elem_type
typedef const RawType const_elem_type; //常量原始数据类型别名 const_elem_type
typedef RawType const sec_const_elem_type; //第二种方式定义的,常量原始数据类型sec_const_elem_type
typedef elem_type const thrd_const_elem_type; //第三种(?)方式定义的,常量原始数据类型thrd_const_elem_type
//以下省略类型二字
typedef RawType& ref_type; // 引用
typedef const RawType& const_ref_type; // 常量引用
typedef RawType* ptr_type; //指针
typedef const RawType* const_ptr_type; //常量指针
typedef RawType *const ptr_const_type; //指针常量
typedef const RawType *const const_ptr_const_type; //常量指针常量
typedef const ptr_type sec_ptr_const_type; //第二方式的指针常量
typedef ptr_type const thrd_ptr_const_type; // 第三方式的指针常量
typedef const const_ptr_type sec_const_ptr_const_type; //第二方式的常量指针常量
typedef const_ptr_type const thrd_ptr_const_type; // 第三方式的常量指针常量PS:
一个typedef 定义的非常量指针类型,不能再次用typedef 定义出常量指针类型
非常量指针,和常量指针,只能用两个不同的 typedef 分别独立定义。
一个typedef 定义的非常量指针类型(别名)
不能用于,定义常量指针对象(数据),没有任何直接的方式可以这样做。