E
ES Kim
Here's a code fragment from TC++PL Special Edition, p291:
void f1(T a)
{
T v[200];
T* p = &v[0];
p--; // please note (my comment)
*p = a; // oops: 'p' out of range, uncaught
++p;
*p = a; // ok
}
And here's an excerpt from p92:
"The result of taking the address of the element before the initial element
is undefined and should be avoided."
The author says, as I understand, it's ok with ++p after p--, which I think
contradict the statement in the excerpt. What do you think?
void f1(T a)
{
T v[200];
T* p = &v[0];
p--; // please note (my comment)
*p = a; // oops: 'p' out of range, uncaught
++p;
*p = a; // ok
}
And here's an excerpt from p92:
"The result of taking the address of the element before the initial element
is undefined and should be avoided."
The author says, as I understand, it's ok with ++p after p--, which I think
contradict the statement in the excerpt. What do you think?