I have the following C++ code:
typedef int* IntPtr; const int* cip = new int; const IntPtr ctip4 = cip;
I compile this with Visual Studio 2
const IntPtr is the same as int* const, not const int*.
const IntPtr
int* const
const int*
That is, it is a const pointer to an int, not a pointer to a const int.
const
int
const int
A solution would be to provide two typedefs:
typedef int* IntPtr; typedef const int* ConstIntPtr;
and use ConstIntPtr when you need a pointer to a const int.
ConstIntPtr