Make your own free website on
C++ Tutorial - Introduction


(Otherwise Known As Lots Of Boring Crap, But Who Knows When You Might End Up On Jeopardy...)


The C programming language was developed at AT&T for the purpose of writing the operating system for the PDP-11 series of computers which ultimately became the UNIX operating system. C was developed with the primary goal of operating efficiency. Bjarne Stroustrup, also of AT&T, developed C++ in order to add object oriented constructs to the C language. Because object oriented technology was new at the time and all existing implementations of object oriented languages were very slow and inefficient, the primary goal of C++ was to maintain the efficiency of C.

C++ can be viewed as a traditional procedural language with some additional constructs. Beginning with C, some constructs are added for object oriented programming and some for improved procedural syntax. A well written C++ program will reflect elements of both object oriented programming style and classic procedural programming. C++ is actually an extendible language since we can define new types in such a way that they act just like the predefined types which are part of the standard language. C++ is designed for large scale software development.


You really can't start coding in C++ until you understand the fundamentals of C, so I suggest going through my C Tutorial before this one. But, as always, you're the client...=)

The best way to learn C++ is by using it. Almost any valid C program is also a valid C++ program and, in fact, the addition of about 12 keywords is the only reason that some C programs will not compile and execute as a C++ program. There are a few other subtle differences, but we will save the discussion of them until later. Since this is true, the best way to learn C++ is to simply add to your present knowledge and use a few new constructs as you need them for each new project. It would be a tremendous mistake to try to use all of the new constructs in your first C++ program. You would probably end up with an incomprehensive mixture of code that would be more inefficient than the same program written purely in C. It would be far better to add a few new constructs to your toolkit occasionally, and use them as needed while you gain experience with their use.


This tutorial is best used while sitting in front of your computer. It is designed to help you gain experience with your own C++ compiler in addition to teaching you the proper use of C++. Display an example program on the monitor, using whatever text editor you usually use, and read the accompanying text which will describe each new construct introduced in the example program. After you study the program, and understand the new constructs, compile and execute the program with your C++ compiler.

After you successfully compile and execute the example program, introduce a few errors into the program to see what kind of error messages are issued. If you have done much programming, you will not be surprised if your compiler gives you an error message that seems to have nothing to do with the error introduced. This is because error message analysis is a very difficult problem with any modern programming language. The most important result of these error introduction exercises is the experience you will gain using your compiler and understanding its nuances. You should then attempt to extend the program using the techniques introduced with the program to gain experience.

The way this tutorial is written, you will not find it necessary to compile and execute every program. At the end of each example program, listed in comments, you will find the result of execution of that program. Some of the constructs are simple and easy for you to understand, so you may choose to ignore compilation and execution of that example program, depending upon the result of execution to give you the output. Some students have used these results of execution to study several chapters of this tutorial on an airplane by referring to a hardcopy of the example programs.

In the text of this tutorial, keywords, variable names, and function names will be written in bold type as an aid when you are studying the example programs.


There are primarily two standards for naming C++ files, one using the extension CPP and the other using the extension CXX. All files in this tutorial use the CPP extension for naming files. If your compiler requires the CXX extension it will be up to you to rename the files. When C++ was in its infancy, header files generally used the extension .HPP, but there is a definite trend to use .H for all header files. For that reason all header files in this tutorial will use that convention.

Even though we have tried to use the most generic form of all constructs, it is possible that some constructs will not actually compile and run with some C++ compilers. As we find new implementations of C++, and acquire copies of them, we will compile and execute all files in an attempt to make all example programs as universal as possible.


There are programming exercises given at the end of each chapter to enable you to try a few of the constructs given in the chapter. These are for your benefit and you will benefit greatly if you attempt to solve each programming problem. If you merely read this entire tutorial, you will have a good working knowledge of C++, but you will only become a C++ programmer if you write C++ programs. The programming exercises are given as suggestions to get you started programming.

The answers to the programming exercises are not online, as that poses too much temptation for some students to just skip the exercises, if you've written code that you think should work, but doesn't, and would like to see my solutions, feel free to email me and I'll send them to you...=)


Margaret Ellis & Bjarne Stroustrup. "The Annotated C++ Reference Manual". Addison-Wesley, 1990. This is the base document for the ANSI-C++ standard. Even though it is the definitive book on C++, it would be difficult for a beginner to learn the language from this book alone.

Scott Meyers. "Effective C++, 50 Specific Ways to Improve Your Programs and Designs". Addison-Wesley, 1992. This book is excellent for the advanced C++ programmer, but it is definitely not for the beginner.

Scott Meyers. "More Effective C++, 35 New Ways to Improve Your Programs and Designs". Addison-Wesley, 1996. This book is excellent for the advanced C++ programmer, following completion of the above reference.

Advance to Chapter 1

Return to the Table of Contents

Copyright © 1998 David Alan Quick - Last update, 16 April 1998
David Alan Quick - -
Please email any comments or suggestions.