For the life of me I cannot find a good explanation of what are the rules that are used to convert a typedef to a C++ statement. The simple cases I understand. But consider this from Danny Kalev:
typedef char * pstr;
int mystrcmp(const pstr, const pstr); //wrong!
Danny Kalev then writes:
The sequence const pstr actually means char * const (a const pointer to char); not const char * (a pointer to const char.
I cannot find anywhere the rule to explain why "const pstr" would be converted to "char * const".
Thanks for any help.
It's because pstr is an alias for char* and when you do const pstr is a bit like saying const (char*) and not (const char)*.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With