The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details.

Programming Languages and Styles

Jonah Cohen

There are many programming languages in the world, and almost as many programming styles (sometimes called paradigms). Three styles that have appeared in this book are procedural, functional, and object-oriented. Although C++ is usually thought of as an object-oriented language, it is possible to write C++ programs in any style. The style I have demonstrated in this book is pretty much procedural. Existing C++ programs and C++ system libraries are written in a mixture of all three styles, but they tend to be more object-oriented than the programs in this book.

It's not easy to define what object-oriented programming is, but here are some of its characteristics:

  • Object definitions (classes) usually correspond to relevant real-world objects. For example, in Chapter 13.3, the creation of the Deck class was a step toward object-oriented programming.
  • The majority of functions are member functions (the kind you invoke on an object) rather than nonmember functions (the kind you just invoke). So far all the functions we have written have been nonmember functions. In this chapter we will write some member functions.
  • The language feature most associated with object-oriented programming is inheritance. I will cover inheritance later in this chapter.

Recently object-oriented programming has become quite popular, and there are people who claim that it is superior to other styles in various ways. I hope that by exposing you to a variety of styles I have given you the tools you need to understand and evaluate these claims.

Last Update: 2005-11-21