C++ Beginner’s Guide (Free E-Book)
Posted by Rubel Khan on August 2, 2009
The following downloads require Adobe Reader:
- Chapter 1
- Chapter 2
- Chapter 3
- Chapter 4
- Chapter 5
- Chapter 6
- Chapter 7
- Chapter 8
- Chapter 9
- Chapter 10
- Chapter 11
- Chapter 12
- Answer Key
- Appendix A
- Chapter 1: C++ Fundamentals
This module will introduce you to C++, its history, its design philosophy, and several of its most important features. This module provides a brief overview of several C++ features, including the general form of a C++ program, some basic control statements, and operators. It does not go into too many details, but rather concentrates on the general concepts common to any C++ program.
- Chapter 2: Introducing Data Types and Operators
At the core of a programming language are its data types and operators. As you might expect, C++ supports a rich assortment of both data types and operators, making it suitable for a wide range of programming. This module will cover an examination of C++’s foundational data types and its most commonly used operators. We will also take a closer look at variables and examine the expression.
- Chapter 3: Program Control Statements
This module discusses the statements that control a program’s flow of execution. There are three categories of program control statements: selection statements, which include the if and the switch; iteration statements, which include thefor, while, and do-while loops; and jump statements, which include break, continue,return, and goto.
- Chapter 4: Arrays, Strings, and Pointers
This module discusses arrays, strings, and pointers. An array is a collection of variables of the same type that are referred to by a common name. Arrays offer a convenient means of creating lists of related variables. The C++ language does not define a built-in string data type. Instead, strings are implemented as arrays of characters. A pointer is an object that contains a memory address. Typically, a pointer is used to access the value of another object.
- Chapter 5: Introducing Functions
This module begins an in-depth discussion of the function. Functions are the building blocks of C++, and a firm understanding of them is fundamental to becoming a successful C++ programmer. Here, you will learn how to create a function. You will also learn about passing arguments, returning values, local and global variables, function prototypes, and recursion.
- Chapter 6: A Closer Look at Functions
This module continues our examination of the function. It discusses three of C++’s most important function-related topics: references, function overloading, and default arguments.
- Chapter 7: More Data Types and Operators
This module returns to the topics of data types and operators. In addition to the data types that you have been using so far, C++ supports several others. Some of these consist of modifiers added to the types you already know about. Other data types include enumerations and typedefs. C++ also provides several additional operators that greatly expand the range of programming tasks to which C++ can be applied.
- Chapter 8: Classes and Objects
The class is C++’s basic unit of encapsulation. Classes are used to create objects. To write object-oriented programs, you will need to use classes. Classes and objects are so fundamental to C++ that much of the remainder of this book is devoted to them in one way or another.
- Chapter 9: A Closer Look at Classes
This module continues the discussion of the class begun in Module 8. It examines a number of class-related topics, including overloading constructors, passing objects to functions, and returning objects. It also describes a special type of constructor, called the copy constructor, which is used when a copy of an object is needed. Next, friend functions are described, followed by structures and unions, and the this keyword. The module concludes with a discussion of operator overloading, one of C++’s most exciting features.
- Chapter 10: Inheritance, Virtual Functions, and Polymorphism
This module discusses three features of C++ that directly relate to object-oriented programming: inheritance, virtual functions, and polymorphism. Inheritance is the feature that allows one class to inherit the characteristics of another. Built on the foundation of inheritance is the virtual function. The virtual function supports polymorphism, the “one interface, multiple methods” philosophy of object-oriented programming.
- Chapter 11: The C++ I/O System
The C++ I/O system is quite large, and it won’t be possible to discuss here every class, function, or feature, but this module will introduce you to the most important and commonly used parts. Specifically, it shows how to input or output objects of classes that you design. It describes how to format output and how to use I/O manipulators. The module ends by discussing file I/O.
- Chapter 12: Exceptions, Templates, and Other Advanced Topics
In the final module, you will examine several important, advanced C++ topics, including exception handling, templates, dynamic allocation, and namespaces. Runtime type ID and the casting operators are also covered. When you finish this module, you will have mastered the core elements of the language and will be able to begin writing real-world programs.
- Answers to Mastery Checks
- Appendix A: The Preprocessor
The preprocessor is that part of the compiler that performs various text manipulations on your program prior to the actual translation of your source code into object code. You can give text manipulation commands to the preprocessor. These commands are called preprocessor directives, and although not technically part of the C++ language, they expand the scope of its programming environment.