Hi there,
I have been struggling for the last days trying to understand one statement made in the book I am reading at the moment (C++ Primer, 5th Ed, page 129)
It tries to explain pointers and typedefs and, for that, gives this bit of code:
typedef string *pstring;
const pstring cstr;
Saying (literally) then: "...what is the type of cstr? The simple answer is that it is a pointer to a const pstring...". After some explanation it concludes then that cstr is a const pointer to a string as well.
OK, I understand at the end cstr is a const pointer to a string (wasn't easy but finally got it), but honestly don't understand why it says it is a pointer to const pstring (note pstring and not strng)...why?? where does the pointer to a pstring come from??
If you could please help me I would be very pleased.
Thanks a lot indeed!!
I have been struggling for the last days trying to understand one statement made in the book I am reading at the moment (C++ Primer, 5th Ed, page 129)
It tries to explain pointers and typedefs and, for that, gives this bit of code:
typedef string *pstring;
const pstring cstr;
Saying (literally) then: "...what is the type of cstr? The simple answer is that it is a pointer to a const pstring...". After some explanation it concludes then that cstr is a const pointer to a string as well.
OK, I understand at the end cstr is a const pointer to a string (wasn't easy but finally got it), but honestly don't understand why it says it is a pointer to const pstring (note pstring and not strng)...why?? where does the pointer to a pstring come from??
If you could please help me I would be very pleased.
Thanks a lot indeed!!