Monday, 12 August 2013

Const pointer and pointer to const

Const pointer and pointer to const

Instead of doing this:
int* const p;
And this:
const int* p;
Couldn't you make it easier to read by doing:
typedef int* ptr;
const ptr p; //Constant pointer to an integer
And:
typedef const int ptr;
ptr* p; //Pointer to a constant integer

No comments:

Post a Comment