K
Kira Yamato
[...]I'm still a newbie in C++, but I'm getting the sense that
proper use of STL should eliminate all needs of pointers.
Where did you get this idea from? Iterators can only be used
for objects in a sequence---in practice, in a container. Most
objects aren't in a container; entity objects never are, since
they aren't copiable, and it's rare to need a pointer for
anything but an entity object.
What is this "entity object" you speak of? Why can't you use
references to "point" to them instead?
'goto' is never needed, even practically.
I'm been told (from friends in the computer department) that "the use
of goto in Linux kernel code is well thought out and justified." Linus
himself cited that use of it can make the code easier to read than with
nested if statements.
Pointers are almost
always needed, even theoretically.
Well, I'm not saying the concept of pointer is unneeded. Certainly,
references is a type of "pointer" to refer to an object. I was
referring to the idea that the STL and C++ reference type & together
should provide sufficient need in place of C++ pointer type *.
(I say almost, because I
believe that there are applications which don't have any
"entity" objects.
What is this entity object again?
I can imagine some serious numeric
applications, for example, which use neither pointers nor
iterators, ever.)
Iterators are for iterating. For the most part, you don't want
to maintain iterators (nor pointers to objects in a container)
for any significant duration; adding or removing elements from
the container can invalidate the iterators. STL containers are
designed with value semantics (the only semantics which really
make sense for a container in the context of C++). This means
that objects in the container do not have identity; they may
"move around".
Ah... Good to know this. Thanks for telling me this or else I might
have introduce hard-to-find bugs.