A variable representing a string is essentially a pointer. An expression has two meanings. The compiler must have a certain logic to handle this situation, otherwise it will be a mess
In fact, the implementation logic of the I/O class in the C++ standard library when overloading <<操作符 is: when encountering char类型指针, it will be treated as a string and the character pointed to by the pointer will be output. string.
To output the address, force conversion to 无类型的指针
cout << static_cast<const void *>(p->a);
*(p->a)Why is T
For a char类型指针 value* operation, of course, it is to obtain the value of a char
A variable representing a string is essentially a pointer. An expression has two meanings. The compiler must have a certain logic to handle this situation, otherwise it will be a mess
In fact, the implementation logic of the I/O class in the C++ standard library when overloading
<<操作符
is: when encounteringchar类型指针
, it will be treated as a string and the character pointed to by the pointer will be output. string.To output the address, force conversion to
无类型的指针
*(p->a)Why is T
For a
char类型指针
value*
operation, of course, it is to obtain the value of a char