What else have I forgotten? |
its hard to say what you know, knew, and forgot.
But a few fun things..
negative indexing is often just not allowed in languages, and is generally frowned upon. But say you wanted to store a signed byte in a counting sort type structure (where array[value] tells you how many of that [value] you have). If you just take a 256 sized array and grab a pointer in the middle, you can then check [-120] from the pointer as a negative array index in the shifted array location.
private/locked/hidden member access/modification. If you can get the address of it, you can hand wave away any const or other preventions and directly access things. Its not generally useful, but if you get into a library (most common for me, hardware interfaces that refuse to expose things that the library knows but won't share) that is determined to keep you out, C and C++ raw pointers can get you (at risk, if the library changes the address can move) the value.
and a lot of it is obsolete. I used to do the copy elision that is now part of C++ using pointers... a function would modify a static variable with the latest result and a pointer to that would directly access it without copying (good for OOP where the copy costs something). Its really nice not having to do that sort of thing, and there are still many other use cases where a pointer to data avoids a copy of that data cleanly... an example is if you want to sort fat data just for a display of it sorted by whatever key, but you don't really want to rearrange its true storage, you can just sort a container of pointers to it which is faster if the objects are fat and disposable as nothing was really done.