Chapter 1: C++ Basics (Summary)

C++ is what might be called an industrial-strength language. It combines the power and efficiency of C with object-oriented features such as classes, inheritance, and polymorphism. C++ is particularly well-suited to writing large, complex software systems that involve teams of programmers. It is also an ideal language for developing libraries that can be easily installed and modified in application programs. C++ is what we call a strongly typed language, meaning that the compiler helps to prevent the use of incorrect expressions involving incompatible data types. Also, function calls across module boundaries are checked against function prototypes to make sure the number and types of the passed arguments agree with the function parameters.

C++ is called a hybrid language because it allows you to mix procedural code and object-oriented code in the same program. This has helped win it acceptance in the C programming community.

Objects represent the real-world entities that play an active part in an application. Designers try to model object-oriented programs around these real-world entities. An object encapsulates (contains) both attributes and operations (also called behaviors). The attributes represent the state of the object, the values of which change at run time. The operations represent the way the object communicates with other objects. A class object is an instance of some class.

A class is a description of the common characteristics shared by all objects of the same type. It is in fact a user-defined data type, with all the rights and privileges (from a language point of view) given to standard data types such as int, float, or double. As we learn to use the tools of C++, we will find that the classes we define can incorporate the same types of operators and implicit conversions available to standard data types.

Inheritance is a powerful tool in object-oriented programming that lets us derive new classes by refining and adding to the attributes and behaviors of existing classes. With inheritance, we can begin with an existing class library and customize it for a particular application.

Polymorphism allows the same name to denote objects of different types. In C++, these types must be classes that are related by inheritance.

We described some of the differences between C and C++, for programmers with a background in C who are moving to C++.

We introduced stream I/O, showing how to write to the standard cout stream object, and how to read from the standard cin stream object. Although the keyboard is the default input device and the screen is the default output device, both input and output can be redirected to other devices.

We briefly introduced reference parameters, a topic that we will cover thoroughly in Chapter 3.