Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
About This E-Book
Title Page
Copyright Page
Contents at a Glance
Table of Contents
About the Authors
We Want to Hear from You!
Reader Services
Introduction
Who Should Read This Book?
Should I Learn C First?
Why Should I Learn C++?
What If I Don’t Want This Book?
Conventions Used in This Book
Part I: Beginning C++
Hour 1. Writing Your First Program
Using C++
Compiling and Linking the Source Code
Creating Your First Program
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 2. Organizing the Parts of a Program
Reasons to Use C++
Styles of Programming
C++ and Object-Oriented Programming
The Parts of a Program
Preprocessor Directives
Source Code Line by Line
Comments
Functions
Using Arguments with Functions
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 3. Creating Variables and Constants
What Is a Variable?
Storing Variables in Memory
Signed and Unsigned Variables
Variable Types
Defining a Variable
Assigning Values to Variables
Using Type Definitions
Constants
Defining Constants
Enumerated Constants
Auto-Typed Variables
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 4. Using Expressions, Statements, and Operators
Statements
Whitespace
Compound Statements
Expressions
Operators
Assignment Operator
Mathematical Operators
Combining Operators
Increment and Decrement Operators
Prefix and Postfix Operators
Operator Precedence
Relational Operators
If-Else Conditional Statements
The Else Clause
Compound If Statements
Logical Operators
AND Operator
OR Operator
NOT Operator
Relational Precedence
Tricky Expression Values
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 5. Calling Functions
What Is a Function?
Declaring and Defining Functions
Using Variables with Functions
Local Variables
Global Variables
Function Parameters
Returning Values from Functions
Default Function Parameters
Overloading Functions
Inline Functions
Auto-Typed Return Values
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 6. Controlling the Flow of a Program
Looping
while Loops
Breaking Out of Loops
Continuing to the Next Loop
do-while Loops
for Loops
Advanced for Loops
Nested Loops
switch Statements
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 7. Storing Information in Arrays and Strings
What Is an Array?
Writing Past the End of Arrays
Initializing Arrays
Multidimensional Arrays
Initializing Multidimensional Arrays
A Word About Memory
Character Arrays
Copying Strings
Reading Arrays with Foreach Loops
Summary
Q&A
Workshop
Quiz
Answers
Activities
Part II: Classes
Hour 8. Creating Basic Classes
What Is a Type?
Creating New Types
Classes and Members
Declaring a Class
Defining an Object
Accessing Class Members
Private Versus Public Access
Implementing Member Functions
Creating and Deleting Objects
Default Constructors
Constructors Provided by the Compiler
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 9. Moving into Advanced Classes
const Member Functions
Interface Versus Implementation
Organizing Class Declarations and Function Definitions
Inline Implementation
Classes with Other Classes as Member Data
Summary
Q&A
Workshop
Quiz
Answers
Activities
Part III: Memory Management
Hour 10. Creating Pointers
Understanding Pointers and Their Usage
Storing the Address in a Pointer
The Indirection Operator, or Using Pointers Indirectly
Pointers, Addresses, and Variables
Manipulating Data by Using Pointers
Examining Addresses Stored in Pointers
Why Use Pointers?
The Stack and the Heap
Using the new Keyword
Using the delete Keyword
Avoiding Memory Leaks
Null Pointer Constant
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 11. Developing Advanced Pointers
Creating Objects on the Heap
Deleting Objects
Accessing Data Members Using Pointers
Member Data on the Heap
The this Pointer
Stray or Dangling Pointers
const Pointers
const Pointers and const Member Functions
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 12. Creating References
What is a Reference?
Creating a Reference
Using the Address of Operator on References
What Can Be Referenced?
Null Pointers and Null References
Passing Function Arguments by Reference
Making swap() Work with Pointers
Implementing swap() with References
Understanding Function Headers and Prototypes
Returning Multiple Values
Returning Values by Reference
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 13. Developing Advanced References and Pointers
Passing by Reference for Efficiency
Passing a const Pointer
References as an Alternative to Pointers
When to Use References and When to Use Pointers
References to Objects Not in Scope
Returning a Reference to an Object on the Heap
Pointer, Pointer, Who Has the Pointer?
Summary
Q&A
Workshop
Quiz
Answers
Activities
Part IV: Advanced C++
Hour 14. Calling Advanced Functions
Overloaded Member Functions
Using Default Values
Initializing Objects
The Copy Constructor
Compile-Time Constant Expressions
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 15. Using Operator Overloading
Operator Overloading
Writing an Increment Method
Overloading the Postfix Operator
Overloading the Addition Operator
Limitations on Operator Overloading
operator=
Conversion Operators
The int() Operator
Summary
Q&A
Workshop
Quiz
Answers
Activities
Part V: Inheritance and Polymorphism
Hour 16. Extending Classes with Inheritance
What Is Inheritance?
Inheritance and Derivation
Animals and Inheritance
The Syntax of Derivation
Private Versus Protected
Constructors and Destructors
Passing Arguments to Base Constructors
Overriding Functions
Overloading Versus Overriding
Hiding the Base Class Member Function
Calling the Base Member Function
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 17. Using Polymorphism and Derived Classes
Polymorphism Implemented with Virtual Member Functions
How Virtual Member Functions Work
You Can’t Get There from Here
Slicing
Virtual Destructors
Virtual Copy Constructors
The Cost of Virtual Member Functions
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 18. Making Use of Advanced Polymorphism
Problems with Single Inheritance
Abstract Data Types
Pure Virtual Functions
Implementing Pure Virtual Functions
Complex Hierarchies of Abstraction
Which Types Are Abstract?
Summary
Q&A
Workshop
Quiz
Answers
Activities
Part VI: Special Topics
Hour 19. Storing Information in Linked Lists
Linked Lists and Other Structures
Linked List Case Study
Delegation of Responsibility
Component Parts
Linked Lists as Objects
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 20. Using Special Classes, Functions, and Pointers
Static Member Data
Static Member Functions
Containment of Classes
Accessing Members of the Contained Class
Filtering Access to Contained Members
Copying by Value Versus by Reference
Friend Classes and Functions
Pointers to Functions
Arrays of Pointers to Functions
Passing Pointers to Functions to Other Functions
Using typedef with Pointers to Functions
Pointers to Member Functions
Arrays of Pointers to Member Functions
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 21. Using New Features of C++14
The Newest Version of C++
Using auto in Function Return Types
Improved Numeric Literals
The constexpr Keyword
Lambda Expressions
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 22. Employing Object-Oriented Analysis and Design
The Development Cycle
Simulating an Alarm System
Conceptualization
Analysis and Requirements
High-Level and Low-Level Design
Other Objects
Designing the Classes
Adding More Classes
Event Loops
PostMaster: A Case Study
Measure Twice, Cut Once
Divide and Conquer
Message Format
Initial Class Design
Rooted Hierarchies Versus Non-Rooted
Designing the Interfaces
Building a Prototype
The 80/80 Rule
Designing the PostMasterMessage Class
The Application Programming Interface
Programming in Large Groups
Ongoing Design Considerations
Working with Driver Programs
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 23. Creating Templates
What Are Templates?
Instances of the Template
Template Definition
Using Template Items
Summary
Q&A
Workshop
Quiz
Answers
Activities
Hour 24. Dealing with Exceptions and Error Handling
Bugs, Errors, Mistakes, and Code Rot
Handling the Unexpected
Exceptions
How Exceptions are Used
Using try and catch Blocks
Catching Exceptions
More Than One Catch
Catching by Reference and Polymorphism
Writing Professional-Quality Code
Braces
Long Lines
switch Statements
Program Text
Identifier Names
Spelling and Capitalization of Names
Comments
Access
Class Definitions
include Files
const
Summary
Q&A
Workshop
Quiz
Answers
Activities
Part VII: Appendixes
Appendix A. Binary and Hexadecimal
Other Bases
Around the Bases
Binary
Why Base 2?
Bits, Bytes, and Nybbles
What’s a KB?
Binary Numbers
Hexadecimal
Appendix B. Glossary
Appendix C. This Book’s Website
Appendix D. Using the MinGW C++ Compiler on Windows
Downloading MinGW-w64
Setting the Path Environment Variable
Testing Your Installation
Opening Folders in MS-DOS
Creating Folders in MS-DOS
Running Programs in MS-DOS
Index
Code Snippets
← Prev
Back
Next →
← Prev
Back
Next →