You need to keep in mind that such a pointer is just a normal variable that contains the address , just as char contains the value of a character. This address can be used to search for another variable (with the * operator).
When you do char* pEmpty = new char , you give pEmpty value returned by new char , which is the address of a piece of memory large enough to hold the char value. Then you use *pEmpty to access this memory and set it to char 'x' .
In the second example, you write pEmpty = 'x' - but remember that pEmpty is a pointer , which means that it must contain an address . Address 'x' ? No, this is a literal symbol! So this line does not make sense.
In the third example, you assign pEmpty string literal "x" . This adress? Yes. A literal evaluates the address of this constant string.
Remember that pointers are a completely different thing from the type they are pointing to. They can be used to access a value of this type, but they are of a completely different type.
source share