Originally Posted by
grumpy
I disagree that it is necessary to learn the "ins and outs" of pointers early when learning C++. What is true is that C++ has often been taught by teaching C first (in fact, in the early days of C++, that was part of the strategy for gaining a critical mass for C++). Since pointers are traditionally introduced quite early when teaching C, that means pointers have been introduced quite early when teaching C++.
In C++, it is actually possible to teach a lot about the use of containers and strings - and use them to do lots of useful things - without needing to discuss pointers at all. It is even possible to avoid mentioning raw (C-style) arrays for quite a while, particularly if one avoids delving into the details of C-style strings (i.e. avoiding mentioning that they're arrays with a zero sentinel) and string literals. It is certainly not necessary to teach about pointers in order to introduce iterators (and, in fact, introduction of iterators can be easier if one glosses over the fact that a pointer is a specialised iterator - it is not necessary to teach about pointers before teaching about iterators).
Yes, it is true that - when learning C++ - it is eventually necessary to delve into the details of raw arrays, string literals, and pointers. But, most teachers of C++ do it too early. However, a few quite successful textbooks have used the approach of leaving introduction of pointers until well after they have introduced containers, strings (as in std::string), and various features of the C++ standard library.
I also consider it would be possible to teach C, but leave the introduction of pointers much later than has been traditional. It is obviously harder than in C++ to avoid teaching about arrays (since there aren't many alternatives in C) and C-style strings, but there are plenty of useful things (again making use of the standard C library) that can be introduced before it is really necessary to thrust those details upon a student.
Yes, I realise that this flies in the face of the way C has been taught for a couple of decades. But bear in mind that the teaching of C hasn't actually changed much since K&R days. Pointers were actually an important feature of B and C, as designed by Dennis Ritchie, because they provided a (relative to what came before) higher level abstraction of addresses in machine memory, and ways of operating on addresses that were much cleaner than typical machine languages. And that is the reason that pointers have traditionally been taught early. Not because they have to be, but because pointers were a feature that was of particular interest (rightly) to the creator of C, so he was focused on ensuring programmers learned pointers as early as possible. But, if you were to ask most moderately experienced (or better) C programmers to name the three things that they found difficult to grasp when learning C, it is a fair bet pointers would be frequently mentioned.
Pointers are actually a very abstract feature of C (and C++), particularly when one includes pointer arithmetic. As laserlight mentioned, quite a few guidelines on teaching programming emphasise the value of teaching concrete "practical" things before teaching abstract things that bend minds out of shape. That suggests the introduction of pointers in both C and C++ should be deferred as much as possible. Not introduced early, as is traditional when teaching C (almost always) and almost-traditional when teaching C++.