Literals and aliasing
Suppose we say
char* x = new char[4];
strcpy(x, ``cat'');
char* y = x;
x[2] = `r';
Then x and y refer to the same object, so changing x[2] changes y[2] also
This makes it hard to treat strings as values
Previous slide
Next slide
Back to first slide
View graphic version