Chapter 3. C++ and Object-Oriented Programming

Table of Contents

Classes in C++
Constructors and Member Initialisation Lists
Classes and Pointers
Class Hierarchy
Static and Dynamic Types
Abstract Classes
C++ Explicit Casts
Method Parameters
Default Parameters
Constant Parameters
Operator Overloading
Multiple Constructors
The copy constructor
Separate Compilation
Dynamic Creation of Objects
Arrays of Objects
Multiple Inheritance
Friend Methods
Static States of Classes
More Scope Resolution Operations
Structs in C++
Unions in C++
Non-Virtual Methods
Inline Methods:
Full Source Code Examples
The Account Class
The Account and CurrentAccount Classes
Multiple Inheritance Example (with problems)
The Multiple Inheritance Example Fixed
A Final Working Version of the Cashsave example
Friend Methods, Pointers to Objects and Destructors
Now with a Copy Constructor!
Destructors and Arrays.

"The problem with using C++ ... is that there's already a strong tendency in the language to require you to know everything before you can do anything."

 --Larry Wall


We discussed the general concepts of classes and objects in the section called “Introduction to Object-Oriented Programming”, now it is time to apply these concepts using the C++ language.