Note_type aliases affect const attribute objects

using and typedefs

typedef int* ix;
using xi = int*;

int a=10;
const int *ra=&a;
const ix td_a=&a;
const xi us_a=&a;
	
int b=100;
ra=&b;
//*ra=10; *ra read-only
//td_a=&b; td_a read-only 
*td_a=20;
//us_a=&b; us_a read-only 
*us_a=30;

If you use using and typedef to set the pointer alias, the const attribute will be added to the pointer instead of the pointed content

Guess you like

Origin blog.csdn.net/Fei_WuYan/article/details/131712391