Skip to content

Absolute C++

ISBN-10: 0132989921

ISBN-13: 9780132989923

Edition: 5th 2013

Authors: Walter Savitch, Kenrick Mock

List price: $179.40
Shipping box This item qualifies for FREE shipping.
Blue ribbon 30 day, 100% satisfaction guarantee!
what's this?
Rush Rewards U
Members Receive:
Carrot Coin icon
XP icon
You have reached 400 XP and carrot coins. That is the daily max!

Description:

Praised for providing an engaging balance of thoughtful examples and explanatory discussion, best-selling author Walter Savitch explains concepts and techniques in a straightforward style using understandable language and code enhanced by a suite of pedagogical tools. Absolute C++is appropriate for both introductory and intermediate C++ programmers.
Customers also bought

Book details

List price: $179.40
Edition: 5th
Copyright year: 2013
Publisher: Addison Wesley
Publication date: 2/21/2012
Binding: Mixed Media
Size: 7.50" wide x 9.00" long x 1.00" tall
Weight: 2.882
Language: English

C++ Basics
Introduction to C++
Origins of the C++ Language
C++ and Object-Oriented Programming
The Character of C++
C++ Terminology
A Sample C++ Program
Variables, Expressions, and Assignment Statements
Identifiers
Variables
Assignment Statements
Pitfall: Uninitialized Variables
Tip: Use Meaningful Names
More Assignment Statements
Assignment Compatibility
Literals
Escape Sequences
Naming Constants
Arithmetic Operators and Expressions
Integer and Floating-Point Division
Pitfall: Division with Whole Numbers
Type Casting
Increment and Decrement Operators
Pitfall: Order of Evaluation
Console Input/Output
Output Using cout
New Lines in Output
Tip: End Each Program with \n or endl
Formatting for Numbers with a Decimal Point
Output with cerr
Input Using cin
Tip: Line Breaks in I/O
Program Style
Comments
Libraries and Namespaces
Libraries and include Directives
Namespaces
Pitfall: Problems with Library Names
Chapter Summary:
Answers to Self-Test Exercises
Programming Projects
Flow of Control
Boolean Expressions
Building Boolean Expressions
Pitfall: Strings of Inequalities
Evaluating Boolean Expressions
Precedence Rules
Pitfall: Integer Values Can Be Used as Boolean Values
Branching Mechanisms
if-else Statements
Compound Statements
Pitfall: Using = in Place of ==
Omitting the else
Nested Statements
Multiway if-else Statement
The switch Statement
Pitfall: Forgetting a break in a switch Statement
Tip: Use switch Statements for Menus
Enumeration Types
The Conditional Operator
Loops
The while and do-while Statements
Increment and Decrement Operators Revisited
The Comma Operator
The for Statement
Tip: Repeat-N-Times Loops
Pitfall: Extra Semicolon in a for Statement
Pitfall: Infinite Loops
The break and continue Statements
Nested Loops
Introduction to File Input
Reading From a Text File Using ifstream
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Function Basics
Predefined Functions
Predefined Functions That Return a Value
Predefined void Functions
A Random Number Generator
Programmer-Defined Functions
Defining Functions That Return a Value
Alternate Form for Function Declarations
Pitfall: Arguments in the Wrong Order
Pitfall: Use of the Terms Parameter and Argument
Functions Calling Functions
Example: A Rounding Function
Functions That Return a Boolean Value
Defining void Functions
return Statements in void Functions
Preconditions and Postconditions
main Is a Function
Recursive Functions
Scope Rules
Local Variables
Procedural Abstraction
Global Constants and Global Variables
Blocks
Nested Scopes
Tip: Use Function Calls in Branching and Loop Statements
Variables Declared in a for Loop
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Parameters and Overloading
Parameters
Call-by-Value Parameters
A First Look at Call-by-Reference Parameters
Call-by-Reference Mechanism in Detail
Constant Reference Parameters
Example: the swapValues Function
Tip: Think of Actions, Not Code
Mixed Parameter Lists
Tip: What Kind of Parameter to Use
Pitfall: Inadvertent Local Variables
Tip: Choosing Formal Parameter Names
Example: Buying Pizza
Overloading and Default Arguments
Introduction to Overloading
Pitfall: Automatic Type Conversion and Overloading
Rules for Resolving Overloading
Example: Revised Pizza-Buying Program
Default Arguments
Testing and Debugging Functions
The assert Macro
Stubs and Drivers
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Arrays
Introduction to Arrays
Declaring and Referencing Arrays
Tip: Use for Loops with Arrays
Pitfall: Array Indexes Always Start with Zero
Tip: Use a Defined Constant for the Size of an Array
Arrays in Memory
Pitfall: Array Index Out of Range
Initializing Arrays
Arrays in Functions
Indexed Variables as Function Arguments
Entire Arrays as Function Arguments
The const Parameter Modifier
Pitfall: Inconsistent Use of const Parameters
Functions That Return an Array
Example: Production Graph
Programming with Arrays
Partially Filled Arrays
Tip: Do Not Skimp on Formal Parameters
Example: Searching an Array
Example: Sorting an Array
Multidimensional Arrays
Multidimensional Array Basics
Multidimensional Array Parameters
Example: Two-Dimensional Grading Program
Chapter Summary
Answers to Self-Test Exercises
Programming projects
Structures and Classes
Structures
Structure Types
Pitfall: Forgetting a Semicolon in a Structure Definition
Structures as Function Arguments
Tip: Use Hierarchical Structures
Initializing Structures
Classes
Defining Classes and Member Functions
Encapsulation
Public and Private Members
Accessor and Mutator Functions
Tip: Separate Interface and Implementation
Tip: A Test for Encapsulation
Structures versus Classes
Tip: Thinking Objects
Chapter Summary
Answers to Self-Tesr Exercises
Programming Projects
Constructors and Other Tools
Constructors
Constructor Definitions
Pitfall: Constructors with No Arguments
Explicit Constructor Calls
Tip: Always Include a Default Constructor
Example: BankAccount Class
Class Type Member Variables
More Tools
The const Parameter Modifier
Pitfall: Inconsistent Use of const
Inline Functions
Static Members
Nested and Local Class Definitions
Vectors A Preview of the Standard Template Library
Vector Basics
Pitfall: Using Square Brackets beyond the Vector Size
Tip: Vector Assignment Is Well Behaved
Efficiency Issues
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Operator Overloading, Friends, and References
Basic Operator Overloading
Overloading Basics
Tip: A Constructor Can Return an Object
Returning by const Value
Tip: Returning Member Variables of a Class Type
Overloading Unary Operators
Overloading as Member Functions
Tip: A Class Has Access to All Its Objects
Overloading Function Application ( )
Pitfall: Overloading &&,, and the Comma Operator
Friend Functions and Automatic Type Conversion
Constructors for Automatic Type Conversion
Pitfall: Member Operators and Automatic Type Conversion
Friend Functions
Friend Classes
Pitfall: Compilers without Friends
References and More Overloaded Operators
References
Pitfall: Returning a Reference to Certain Member Variables
Overloading >> and <<
Tip: What Mode of Returned Value to Use
The Assignment Operator
Overloading the Increment and Decrement Operators
Overloading the Array Operator [ ]
Overloading Based on L-Value versus R-Value
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Strings
An Array Type for Strings
C-String Values and C-String Variables
Pitfall: Using = and == with C-strings
Other Functions in
Example: Command-Line Arguments
C-String Input and Output
Character Manipulation Tools
Character I/O
The Member Functions get and put
Example: Checking Input Using a Newline Function
Pitfall: Unexpected '\n' in Input
The putback, peek, and ignore Member Functions
Character-Manipulating Functions
Pitfall: toupper and tolower Return int Values
the Standard Class string
Introduction to the Standard Class string
I/O with the Class string
Tip: More Versions of getline
Pitfall: Mixing cin >> variable; and getline
String Processing with the Class string
Example: Palindrome Testing
Converting between string Objects and C-Strings
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Pointers and Dynamic Arrays
Pointers
Pointer Variables
Basic Memory Management
Pitfall: Dangling Pointers
Dynamic Variables and Automatic Variables
Tip: Define Pointer Types
Pitfall: Pointers as Call-by-Value Parameters
Uses for Pointers
Dynamic Arrays
Array Variables and Pointer Variables
Creating and Using Dynamic Arrays
Example: A Function That Returns an Array
Pointer Arithmetic
Multidimensional Dynamic Arrays
Classes, Pointers, and Dynamic Arrays
The -> Operator
The this Pointer
Overloading the Assignment Operator
Example: A Class for Partially Filled Arrays
Destructors
Copy Constructors
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Separate Compilation and Namespaces
Separate Compilation
Encapsulation Reviewed
Header Files and Implementation Files
Example: DigitalTime Class
Tip: Reusable Components
Using #ifndef
Tip: Defining Other Libraries
Namespaces
Namespaces and using Directives
Creating a Namespace
Using Declarations
Qualifying Names
Tip: Choosing a Name for a Namespace
Example: A Class Definition in a Namespace
Unnamed Namespaces
Pitfall: Confusing the Global Namespace and the Unnamed Namespace
Tip: Unnamed Namespaces Replace the static Qualifier
Tip: Hiding Helping Functions
Nested Namespaces
Tip: What Namespace Specification Should You Use?
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Streams and File I/O
I/O Streams
File I/O
Pitfall: Restrictions on Stream Variables
Appending to a File
Tip: Another Syntax for Opening a File
Tip: Check That a File Was Opened Successfully
Character I/O
Checking for the End of a File
Tools for Stream I/O
File Names as Input
Formatting Output with Stream Functions
Manipulators
Saving Flag Settings
More Output Stream Member Functions
Example: Cleaning Up a File Format
Example: Editing a Text File
Stream Hierarchies: A Preview of Inheritance
Inheritance among Stream Classes
Example: Another newLine Function
Parsing Strings with the stringstream Class
Random Access to Files
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Recursion
Recursive void Functions
Example: Vertical Numbers
Tracing a Recursive Call
A Closer Look at Recursion
Pitfall: Infinite Recursion
Stacks for Recursion
Pitfall: Stack Overflow
Recursion versus Iteration
Recursive Functions That Return a Value
General Form for a Recursive Function That Returns a Value
Example: Another Powers Function
Mutual Recursion
Thinking Recursively
Recursive Design Techniques
Binary Search
Coding
Checking the Recursion
Efficiency
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Inheritance
Inheritance Basics
Derived Classes
Constructors in Derived Classes
Pitfall: Use of Private Member Variables from the Base Class
Pitfall: Private Member Functions Are Effectively Not Inherited
The protected Qualifier
Redefinition of Member Functions
Redefining versus Overloading
Access to a Redefined Base Function
Functions That Are Not Inherited
Programming with Inheritance
Assignment Operators and Copy Constructors in Derived Classes
Destructors in Derived Classes
Example: Partially Filled Array with Backup
Pitfall: Same Object on Both Sides of the Assignment Operator
Example: Alternate Implementation of PFArrayDBak
Tip: A Class Has Access to Private Members of All Objects of the Class
Tip: "Is a" versus "Has a"
Protected and Private Inheritance
Multiple Inheritance
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Polymorphism and Virtual Functions
Virtual Function Basics
Late Binding
Virtual Functions in C++
Tip: the Virtual Property Is Inherited
Tip: When to Use a Virtual Function
Pitfall: Omitting the Definition of a Virtual Member Function
Abstract Classes and Pure Virtual Functions
Example: An Abstract Class
Pointers and Virtual Functions
Virtual Functions and Extended Type Compatibility
Pitfall: the Slicing Problem
Tip: Make Destructors Virtual
Downcasting and Upcasting
How C++ Implements Virtual Functions
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Templates
Function Templates
Syntax for Function Templates
Pitfall: Compiler Complications
Tip: How to Define Templates
Example: A Generic Sorting Function
Pitfall: Using a Template with an Inappropriate Type
Class Templates
Syntax for Class Templates
Example: An Array Template Class
The vector and basic_string Templates
Templates and Inheritance
Example: Template Class for a Partially Filled Array with Backup
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Linked Data Structures
Nodes and Linked Lists
Nodes
Linked Lists
Inserting a Node at the Head of a List
Pitfall: Losing Nodes
Inserting and Removing Nodes Inside a List
Pitfall: Using the Assignment Operator with Dynamic Data Structures
Searching a Linked List
Doubly Linked Lists
Adding a Node to a Doubly Linked List
Deleting a Node from a Doubly Linked List
Example: A Generic Sorting Template Version of Linked List Tools
Linked List Applications
Example: A Stack Template Class
Example: A Queue Template Class
Tip: A Comment on Namespaces
Friend Classes and Similar Alternatives
Example: Hash Tables with Chaining
Efficiency of Hash Tables
Example: A Set Template Class
Efficiency of Sets Using Linked Lists
Iterators
Pointers as Iterators
Iterator Classes
Example: An Iterator Class
Trees
Tree Properties
Example: A Tree Template Class
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Exception Handling
Exception Handling Basics
A Toy Example of Exception Handling
Defining Your Own Exception Classes
Multiple Throws and Catches
Pitfall: Catch the More Specific Exception First
Tip: Exception Classes Can Be Trivial
Throwing an Exception in a Function
Exception Specification
Pitfall: Exception Specification in Derived Classes
Programming Techniques for Exception Handling
When to Throw an Exception
Pitfall: Uncaught Exceptions
Pitfall: Nested try-catch Blocks
Pitfall: Overuse of Exceptions
Exception Class Hierarchies
Testing for Available Memory
Rethrowing an Exception
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Standard Template Library
Iterators
Iterator Basics
Pitfall: Compiler Problems
Kinds of Iterators
Constant and Mutable Iterators
Reverse Iterators
Other Kinds of Iterators
Containers
Sequential Containers
Pitfall: Iterators and Removing Elements
Tip: Type Definitions in Containers
The Container Adapters stack and queue
Pitfall: Underlying Containers
The Associative Containers set and map
Efficiency
Generic Algorithms
Running Times and Big-O Notation
Container Access Running Times
Nonmodifying Sequence Algorithms
Modifying Sequence Algorithms
Set Algorithms
Sorting Algorithms
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
Patterns and UML
Patterns
Adapter Pattern
The Model-View-Controller Pattern
Example: A Sorting Pattern
Efficiency of the Sorting Pattern
Tip: Pragmatics and Patterns
Pattern Formalism
UML
History of UML
UML Class Diagrams
Class Interactions
Chapter Summary
Answers to Self-Test Exercises
Programming Projects
C++ Keywords
Precedence of Operators
the ASCII Character Set
Some Library Functions
Old and New Header Files
Index