Chapter 2. Introduction to C++ (The "C" of C++)

Table of Contents

Introduction
A First Application
Setting up a compiler
General Language
Variables
typedef
Namespaces
Comments
Methods (or Functions) in C++
Strings in C++
cin
Assignment statements
Scope of Variables
Pointers in C/C++
C++ Expressions
Precedence Reference:

Introduction

 

"C gives you enough rope to hang yourself. C++ also gives you the tree object to tie it to."

 
 --Unknown

C++ is an object-oriented language. So to use C++:

  • Engineers define classes and create objects from these classes.

  • Compose an application from existing and new C++ modules.

  • Decompose the application into modules.

C++ was developed by Bjarne Stroustrup [4] at Bell Labs (now AT&T Labs) during 1983-1985. It is based on the C language (named in 1972) that was developed at AT&T for Unix systems in the early 70's (1969-1973) by Dennis Ritchie. Believe it or not, the C language was a descendent of the B language developed in 1970 by Ken Thompson, which in turn was a descendent of the BCPL language developed by Martin Richards, a Cambridge Student visiting MIT.

As well as adding object-oriented technologies (originally he called it C with Classes), C++ also improves the C language by adding features such as better type checking. The language very quickly came into widespread use and is today one of the best known object-oriented languages. The fast uptake was mainly due to its similarity to the C programming syntax, being an extension to the C language that allowed existing C code to be used when possible. C++ is not a purely object-oriented language, rather it is a hybrid - having both the organisational structure of object-oriented languages, but retaining the efficiencies of C, such as types, pointers etc.

In 1998 the ANSI/ISO (American Standard Institute/International Organization for Standardisation) committee adopted a worldwide uniform language specification that was to remove inconsistencies between the various C++ compilers [5]. Unfortunately not all compilers support this standard, even today. This is a problem with C++, as each vendor can have their own flavour of C++, where code developed on one compiler on one operating system may not necessarily compile on another compiler on another operating system.



[4] Bjarne Stroustrup home page: http://www.research.att.com/~bs/homepage.html

[5] The final technical vote took place November 14, 1997. After the technical vote, the standard was ratified in 1998 by a 22-0 national vote. The standard is ISO/IEC 14882 and is available at the ANSI Webstore, price $18 (2004) ANSI Webstore