Sams Teach Yourself C++ in 24 Hours is a hands-on guide to the C++ programming language. Readers are provided with short, practical examples that illustrate key concepts, syntax, and techniques.
Using a straightforward approach, this fast and friendly tutorial teaches you everything you need to know, from installing and using a compiler, to debugging the programs you've created, to what's new in C++14.
Step-by-step instructions carefully walk you through the most common C++ programming tasks
Quizzes and exercises at the end of each chapter help you test yourself to make sure you're ready to go on
Learn how to...
Install and use a C++ compiler for Windows, Mac OS X, or Linux Build object-oriented programs in C++ Master core C++ concepts such as functions and classes Add rich functionality with templates and lambda expressions Debug your programs for flawless code Learn exception and error-handling techniques Put to use the new features in C++14, the latest version of the language Create and use templates Control program flow with loops Store information in arrays and strings Declare and use pointers Use operator overloading Extend classes with inheritance Use polymorphism and derived classes Employ object-oriented analysis and design
Author(s): Rogers Cadenhead; Jesse Liberty
Edition: 6
Publisher: Sams Publishing
Year: 2016
Language: English
Pages: 480
Cover
Title Page
Copyright Page
Table of Contents
Introduction
Part I: Beginning C++
HOUR 1: Writing Your First Program
Using C++
Compiling and Linking the Source Code
Creating Your First Program
HOUR 2: Organizing the Parts of a Program
Reasons to Use C++
The Parts of a Program
Comments
Functions
HOUR 3: Creating Variables and Constants
What Is a Variable?
Defining a Variable
Assigning Values to Variables
Using Type Definitions
Constants
Auto-Typed Variables
HOUR 4: Using Expressions, Statements, and Operators
Statements
Expressions
Operators
If-Else Conditional Statements
Logical Operators
Tricky Expression Values
HOUR 5: Calling Functions
What Is a Function?
Declaring and Defining Functions
Using Variables with Functions
Function Parameters
Returning Values from Functions
Default Function Parameters
Overloading Functions
Auto-Typed Return Values
HOUR 6: Controlling the Flow of a Program
Looping
while Loops
do-while Loops
for Loops
switch Statements
HOUR 7: Storing Information in Arrays and Strings
What Is an Array?
Writing Past the End of Arrays
Initializing Arrays
Multidimensional Arrays
Character Arrays
Copying Strings
Reading Arrays with Foreach Loops
Part II: Classes
HOUR 8: Creating Basic Classes
What Is a Type?
Creating New Types
Classes and Members
Accessing Class Members
Private Versus Public Access
Implementing Member Functions
Creating and Deleting Objects
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
Part III: Memory Management
HOUR 10: Creating Pointers
Understanding Pointers and Their Usage
The Stack and the Heap
Null Pointer Constant
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
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
Understanding Function Headers and Prototypes
Returning Multiple Values
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?
Part IV: Advanced C++
HOUR 14: Calling Advanced Functions
Overloaded Member Functions
Using Default Values
Initializing Objects
The Copy Constructor
Compile-Time Constant Expressions
HOUR 15: Using Operator Overloading
Operator Overloading
Conversion Operators
Part V: Inheritance and Polymorphism
HOUR 16: Extending Classes with Inheritance
What Is Inheritance?
Private Versus Protected
Constructors and Destructors
Passing Arguments to Base Constructors
Overriding Functions
HOUR 17: Using Polymorphism and Derived Classes
Polymorphism Implemented with Virtual Member Functions
How Virtual Member Functions Work
HOUR 18: Making Use of Advanced Polymorphism
Problems with Single Inheritance
Abstract Data Types
Part VI: Special Topics
HOUR 19: Storing Information in Linked Lists
Linked Lists and Other Structures
Linked List Case Study
Linked Lists as Objects
HOUR 20: Using Special Classes, Functions, and Pointers
Static Member Data
Static Member Functions
Containment of Classes
Friend Classes and Functions
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
HOUR 22: Employing Object-Oriented Analysis and Design
The Development Cycle
Simulating an Alarm System
PostMaster: A Case Study
HOUR 23: Creating Templates
What Are Templates?
Instances of the Template
Template Definition
Using Template Items
HOUR 24: Dealing with Exceptions and Error Handling
Bugs, Errors, Mistakes, and Code Rot
Handling the Unexpected
Exceptions
Using try and catch Blocks
Writing Professional-Quality Code
Part VII: Appendixes
APPENDIX A: Binary and Hexadecimal
Other Bases
Around the Bases
Hexadecimal
APPENDIX B: Glossary
A
B
C
D
E
F
G
H
I
L
M
O
P
R
S
T
U
V
W
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
Index
A
B
C
D
E
F
G
H
I
J-K
L
M
N
O
P
Q-R
S
T
U
V
W-X-Y-Z