struct Example { char* string; int x; }; When I allocate a new instance of Example 8 bytes are allocated (assuming that sizeof(char*)=4). So when I call this:
Example* sp = new Example(); sp->string = "some text"; How is the string allocated? Is is placed in a random empty memory location? or is there some kind of relation between sp and member string?
So, "some text" makes a dynamic memory allocation?
const char*. The code as written is using a deprecated conversion fromconst char[10]tochar*, discarding aconston the way.