Learning/Teaching C++ the way I learned Java
My introduction to C++ was a week long in-house course for experienced C programmers back in 1990. The course started out by introducing class definitions, public, protected and private data. Then we quickly moved on to virtual functions, inheritance and polymorphism. This was pretty intense and a bit overwhelming for a bunch of C programmers whose only knowledge of classes and objects came from a quick read of Grady Booch’s Object-Oriented Analysis and Design with Applications. Classes and objects were purely theoretical constructs to us and our course used some pretty random examples. But this is the normal sequence for C++ instruction. Teach C then teach class definition, constructors and all the rest with very little motivation for using classes.
When I learned Java, the approach was quite different. We started using classes from Java’s vast array of class libraries from the start. Then we were taught how to define our own classes. We learned about inheritance and polymorphism through the use of container classes then we learned how to write class and interface hierarchies.
Now I find myself teaching a short course at work in C++ programming for experienced C programmers. I was delighted to find a book, Accelerated C++: Practical Programming by Example, which teaches C++ programming the way I learned Java programming. From the first chapter, the examples and problems use classes from the C++ Standard Library. Only after writing programs using real, useful classes do you learn how to create your own classes. I am convinced that this approach leads to a deeper understanding and appreciation of object oriented programming in C++ and the C++ Standard Library.







