did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780321268655

Problem Solving with C++ : The Object of Programming

by
  • ISBN13:

    9780321268655

  • ISBN10:

    0321268652

  • Edition: 5th
  • Format: Paperback
  • Copyright: 2005-01-01
  • Publisher: Addison Wesley
  • View Upgraded Edition
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $112.40

Summary

Enables readers to efficiently master the fundamentals of C++ and object-oriented programming, while imparting skills that are valuable with virtually any contemporary programming language.Writing in a friendly, highly motivational style, Walter Savitch begins with an overview of programming and problem-solving, then walks through all the fundamentals of C++ development. Coverage includes: variables, assignments, I/O, data types, expressions, flow control, functions, arrays, strings, vectors, pointers, and recursion, along with complete chapters on inheritance, exception handling, and templates. From start to finish, Savitch presents C++ examples in the context of complete, executable programs that are available for download. This edition fully embraces the latest ANSI/ISO standards, features an all-new chapter on the STL, and includes expanded coverage of namespaces. Improvements also include: access to Addison-Wesley's exclusive online CodeMate program competency builder; an all-new, full-color design, and many new exercises.For anyone who wants to master object-oriented programming with C++: both those who have experience with other languages, and those learning programming for the first time

Author Biography

Walter Savitch, who teaches at the University of California at San Diego, brings his rich experience as both a successful teacher and best-selling author to this new text, his fifth Addison-Wesley book. His other books include the highly successful introductory programming texts Pascal and Turbo Pascal, both in 4th editions, Ada (with Charles Petersen), and the recent Data Structures and Other Objects (with Michael Main).

Table of Contents

Introduction to Computers and C++ Programming
1(34)
Computer Systems
3(9)
Hardware
3(4)
Software
7(1)
High-Level Languages
8(1)
Compilers
9(2)
History Note
11(1)
Programming and Problem-Solving
12(6)
Algorithms
13(1)
Program Design
14(1)
Object-Oriented Programming
15(2)
The Software Life Cycle
17(1)
Introduction to C++
18(10)
Origins of the C++ Language
18(1)
A Sample C++ Program
19(3)
Pitfall: Using the Wrong Slash in \n
22(1)
Programming Tip: Input and Output Syntax
22(1)
Layout of a Simple C++ Program
23(2)
Pitfall: Putting a Space before the include File Name
25(1)
Compiling and Running a C++ Program
25(1)
Programming Tip: Getting Your Program to Run
26(2)
Testing and Debugging
28(7)
Kinds of Program Errors
28(1)
Pitfall: Assuming Your Program Is Correct
29(1)
Chapter Summary
30(1)
Answers to Self-Test Exercises
31(2)
Programming Projects
33(2)
C++ Basics
35(62)
Variables and Assignments
37(9)
Variables
37(1)
Names: Identifiers
38(2)
Variable Declarations
40(1)
Assignment Statements
41(2)
Pitfall: Uninitialized Variables
43(2)
Programming Tip: Use Meaningful Names
45(1)
Input and Output
46(9)
Output Using cout
46(1)
Include Directives and Namespaces
47(2)
Escape Sequences
49(1)
Programming Tip: End Each Program with a \n or end1
50(1)
Formatting for Numbers with a Decimal Point
50(1)
Input Using cin
51(2)
Designing Input and Output
53(1)
Programming Tip: Line Breaks in I/O
53(2)
Data Types and Expressions
55(10)
The Types int and double
55(1)
Other Number Types
56(2)
The Type char
58(1)
The Type bool
58(1)
Type Compatibilities
59(2)
Arithmetic Operators and Expressions
61(2)
Pitfall: Whole Numbers in Division
63(2)
More Assignment Statements
65(1)
Simple Flow of Control
65(18)
A Simple Branching Mechanism
66(5)
Pitfall: Strings of Inequalities
71(1)
Pitfall: Using = in place of ==
71(1)
Compound Statements
72(2)
Simple Loop Mechanisms
74(3)
Increment and Decrement Operators
77(2)
Programming Example: Charge Card Balance
79(1)
Pitfall: Infinite Loops
80(3)
Program Style
83(14)
Indenting
84(1)
Comments
84(1)
Naming Constants
85(3)
Chapter Summary
88(1)
Answers to Self-Test Exercises
89(5)
Programming Projects
94(3)
Procedural Abstraction and Functions That Return a Value
97(58)
Top-Down Design
99(1)
Predefined Functions
99(8)
Using Predefined Functions
99(5)
Type Casting
104(1)
Older Form of Type Casting
105(1)
Pitfall: Integer Division Drops the Fractional Part
106(1)
Programmer-Defined Functions
107(10)
Function Definitions
107(4)
Alternate Form for Function Declarations
111(3)
Pitfall: Arguments in the Wrong Order
114(1)
Function Definition-Syntax Summary
114(2)
More About Placement of Function Definitions
116(1)
Procedural Abstraction
117(11)
The Black Box Analogy
117(3)
Programming Tip: Choosing Formal Parameter Names
120(1)
Case Study: Buying Pizza
120(7)
Programming Tip: Use Pseudocode
127(1)
Local Variables
128(12)
The Small Program Analogy
128(2)
Programming Example: Experimental Pea Patch
130(1)
Global Constants and Global Variables
131(2)
Call-by-Value Formal Parameters Are Local Variables
133(1)
Namespaces Revisited
134(4)
Programming Example: The Factorial Function
138(2)
Overloading Function Names
140(15)
Introduction to Overloading
140(3)
Programming Example: Revised Pizza-Buying Program
143(3)
Automatic Type Conversion
146(2)
Chapter Summary
148(1)
Answers to Self-Test Exercises
149(3)
Programming Projects
152(3)
Functions for All Subtasks
155(44)
Void Functions
157(7)
Definitions of void Functions
157(2)
Programming Example: Converting Temperatures
159(1)
return Statements in void Functions
159(5)
Call-by-Reference Parameters
164(12)
A First View of Call-by-Reference
164(1)
Call-by-Reference in Detail
165(5)
Programming Example: The swap_values Function
170(2)
Mixed Parameter Lists
172(1)
Programming Tip: What Kind of Parameter to Use
172(2)
Pitfall: Inadvertent Local Variables
174(2)
Using Procedural Abstraction
176(10)
Functions Calling Functions
176(1)
Preconditions and Postconditions
177(3)
Case Study: Supermarket Pricing
180(6)
Testing and Debugging Functions
186(13)
Stubs and Drivers
186(5)
Chapter Summary
191(1)
Answers to Self-Test Exercises
192(3)
Programming Projects
195(4)
I/O Streams as an Introduction to Objects and Classes
199(70)
Streams and Basic File I/O
201(15)
Why Use Files for I/O?
201(1)
File I/O
202(4)
Introduction to Classes and Objects
206(2)
Programming Tip: Check Whether a File Was Opened Successfully
208(1)
Techniques for File I/O
209(4)
Appending to a File (Optional)
213(1)
File Names as Input (Optional)
213(3)
Tools for Stream I/O
216(15)
Formatting Output with Stream Functions
216(5)
Manipulators
221(4)
Streams as Arguments to Functions
225(1)
Programming Tip: Checking for the End of a File
225(4)
A Note on Namespaces
229(1)
Programming Example: Cleaning Up a File Format
230(1)
Character I/O
231(18)
The Member Functions get and put
231(4)
The putback Member Function (Optional)
235(1)
Programming Example: Checking Input
235(3)
Pitfall: Unexpected `\n' in Input
238(3)
The eof Member Function
241(2)
Programming Example: Editing a Text File
243(1)
Predefined Character Functions
244(3)
Pitfall: toupper and tolower Return Values
247(2)
Inheritance
249(20)
Inheritance Among Stream Classes
249(4)
Programming Example: Another new_line Function
253(1)
Default Arguments for Functions (Optional)
254(2)
Chapter Summary
256(1)
Answers to Self-Test Exercises
257(7)
Programming Projects
264(5)
Defining Classes
269(64)
Structures
271(11)
Structures for Diverse Data
271(5)
Pitfall: Forgetting a Semicolon in a Structure Definition
276(1)
Structures as Function Arguments
276(1)
Programming Tip: Use Hierarchical Structures
277(2)
Initializing Structures
279(3)
Classes
282(33)
Defining Classes and Member Functions
282(5)
Public and Private Members
287(6)
Programming Tip: Make All Member Variables Private
293(2)
Programming Tip: Define Accessor and Mutator Functions
295(2)
Programming Tip: Use the Assignment Operator with Objects
297(1)
Programming Example: BankAccount Class--Version 1
297(5)
Summary of Some Properties of Classes
302(2)
Constructors for Initialization
304(8)
Programming Tip: Always Include a Default Constructor
312(1)
Pitfall: Constructors with No Arguments
313(2)
Abstract Data Types
315(18)
Classes to Produce Abstract Data Types
315(4)
Programming Example: Alternative Implementation of a Class
319(4)
Chapter Summary
323(1)
Answers to Self-Test Exercises
324(5)
Programming Projects
329(4)
More Flow of Control
333(70)
Using Boolean Expressions
335(8)
Evaluating Boolean Expressions
335(4)
Pitfall: Boolean Expressions Convert to int Values
339(2)
Functions That Return a Boolean Value
341(1)
Enumeration Types (Optional)
342(1)
Multiway Branches
343(21)
Nested Statements
343(1)
Programming Tip: Use Braces in Nested Statements
343(4)
Multiway if-else Statements
347(2)
Programming Example: State Income Tax
349(3)
The switch Statement
352(4)
Pitfall: Forgetting a break in a switch Statement
356(1)
Using switch Statements for Menus
357(1)
Programming Tip: Use Function Calls in Branching Statements
357(1)
Blocks
357(6)
Pitfall: Inadvertent Local Variables
363(1)
More About C++ Loop Statements
364(15)
The while Statements Reviewed
364(2)
Increment and Decrement Operators Revisited
366(3)
The for Statement
369(4)
Pitfall: Extra Semicolon in a for Statement
373(2)
What Kind of Loop to Use
375(2)
Pitfall: Uninitialized Variables and Infinite Loops
377(1)
The break Statement
377(1)
Pitfall: The break Statement in Nested Loops
377(2)
Designing Loops
379(24)
Loops for Sums and Products
379(2)
Ending a Loop
381(3)
Nested Loops
384(5)
Debugging Loops
389(3)
Chapter Summary
392(1)
Answers to Self-Test Exercises
393(5)
Programming Projects
398(5)
Friends and Overloaded Operators
403(52)
Friend Functions
405(23)
Programming Example: An Equality Function
405(4)
Friend Functions
409(2)
Programming Tip: Define Both Accessor Functions and Friend Functions
411(2)
Programming Tip: Use Both Member and Nonmember Functions
413(1)
Programming Example: Money Class (Version 1)
413(7)
Implementation of digit_to_int (Optional)
420(1)
Pitfall: Leading Zeros in Number Constants
421(2)
The const Parameter Modifier
423(1)
Pitfall: Inconsistent Use of const
424(4)
Overloading Operators
428(27)
Overloading Operators
428(3)
Constructors for Automatic Type Conversion
431(2)
Overloading Unary Operators
433(1)
Overloading >> and <<
434(11)
Chapter Summary
445(1)
Answers to Self-Test Exercises
445(7)
Programming Projects
452(3)
Separate Compilation and Namespaces
455(36)
Separate Compilation
457(14)
ADTs Reviewed
457(1)
Case Study: DigitalTime--A Class Compiled Separately
458(10)
Using #ifndef
468(2)
Programming Tip: Defining Other Libraries
470(1)
Namespaces
471(20)
Namespaces and using Directives
471(2)
Creating a Namespace
473(3)
Qualifying Names
476(1)
A Subtle Point About Namespaces (Optional)
477(1)
Unnamed Namespaces
478(6)
Programming Tip: Choosing a Name for a Namespace
484(1)
Pitfall: Confusing the Global Namespace and the Unnamed Namespace
484(2)
Chapter Summary
486(1)
Answers to Self-Test Exercises
486(2)
Programming Projects
488(3)
Arrays
491(76)
Introduction to Arrays
493(9)
Declaring and Referencing Arrays
493(1)
Programming Tip: Use for Loops with Arrays
494(1)
Pitfall: Array Indexes Always Start with Zero
494(2)
Programming Tip: Use a Defined Constant for the Size of an Array
496(1)
Arrays in Memory
496(2)
Pitfall: Array Index Out of Range
498(1)
Initializing Arrays
498(4)
Arrays in Functions
502(22)
Indexed Variables as Function Arguments
502(2)
Entire Arrays as Function Arguments
504(3)
The const Parameter Modifier
507(2)
Pitfall: Inconsistent Use of const Parameters
509(1)
Functions That Return an Array
510(1)
Case Study: Production Graph
510(14)
Programming with Arrays
524(12)
Partially Filled Arrays
525(1)
Programming Tip: Do Not Skimp on Formal Parameters
525(3)
Programming Example: Searching an Array
528(3)
Programming Example: Sorting an Array
531(5)
Arrays and Classes
536(9)
Arrays of Classes
536(3)
Arrays as Class Members
539(2)
Programming Example: A Class for a Partially Filled Array
541(4)
Multidimensional Arrays
545(22)
Multidimensional Array Basics
545(1)
Multidimensional Array Parameters
545(2)
Programming Example: Two-Dimensional Grading Program
547(5)
Pitfall: Using Commas Between Array Indexes
552(1)
Chapter Summary
553(1)
Answers to Self-Test Exercises
553(6)
Programming Projects
559(8)
Strings and Vectors
567(48)
An Array Type for Strings
569(17)
C-String Values and C-String Variables
569(3)
Pitfall: Using = and == with C Strings
572(2)
Other Functions in <cstring>
574(4)
C-String Input and Output
578(3)
C-String-to-Number Conversions and Robust Input
581(5)
The Standard string Class
586(17)
Introduction to the Standard Class string
587(2)
I/O with the Class string
589(4)
Programming Tip: More Versions of getline
593(1)
Pitfall: Mixing cin >> variable; and getline
594(1)
String Processing with the Class string
595(2)
Programming Example: Palindrome Testing
597(6)
Converting between string Objects and C Strings
603(1)
Vectors
603(12)
Vector Basics
604(1)
Pitfall: Using Square Brackets Beyond the Vector Size
605(2)
Programming Tip: Vector Assignment Is Well Behaved
607(1)
Efficiency Issues
607(2)
Chapter Summary
609(1)
Answers to Self-Test Exercises
610(2)
Programming Projects
612(3)
Pointers and Dynamic Arrays
615(46)
Pointers
617(11)
Pointer Variables
617(7)
Basic Memory Management
624(1)
Pitfall: Dangling Pointers
625(1)
Static Variables and Automatic Variables
626(1)
Programming Tip: Define Pointer Types
626(2)
Dynamic Arrays
628(9)
Array Variables and Pointer Variables
629(1)
Creating and Using Dynamic Arrays
629(6)
Pointer Arithmetic (Optional)
635(2)
Multidimensional Dynamic Arrays (Optional)
637(1)
Classes and Dynamic Arrays
637(24)
Programming Example: A String Variable Class
639(1)
Destructors
640(6)
Pitfall: Pointers as Call-by-Value Parameters
646(2)
Copy Constructors
648(4)
Overloading the Assignment Operator
652(3)
Chapter Summary
655(1)
Answers to Self-Test Exercises
655(2)
Programming Projects
657(4)
Recursion
661(40)
Recursive Functions for Tasks
663(12)
Case Study: Vertical Numbers
663(6)
A Closer Look at Recursion
669(1)
Pitfall: Infinite Recursion
670(2)
Stacks for Recursion
672(1)
Pitfall: Stack Overflow
673(1)
Recursion versus Iteration
674(1)
Recursive Functions for Values
675(5)
General Form for a Recursive Function That Returns a Value
675(1)
Programming Example: Another Powers Function
676(4)
Thinking Recursively
680(21)
Recursive Design Techniques
680(2)
Case Study: Binary Search---An Example of Recursive Thinking
682(7)
Programming Example: A Recursive Member Function
689(5)
Chapter Summary
694(1)
Answers to Self-Test Exercises
695(3)
Programming Projects
698(3)
Templates
701(28)
Templates for Algorithm Abstraction
703(11)
Templates for Functions
704(3)
Pitfall: Compiler Complications
707(2)
Programming Example: A Generic Sorting Function
709(4)
Programming Tip: How to Define Templates
713(1)
Pitfall: Using a Template with an Inappropriate Type
714(1)
Templates for Data Abstraction
714(15)
Syntax for Class Templates
715(3)
Programming Example: An Array Class
718(6)
Chapter Summary
724(1)
Answers to Self-Test Exercises
724(3)
Programming Projects
727(2)
Pointers and Linked Lists
729(42)
Nodes and Linked Lists
731(21)
Nodes
731(4)
Linked Lists
735(1)
Inserting a Node at the Head of a List
736(4)
Pitfall: Losing Nodes
740(1)
Searching a Linked List
741(2)
Pointers as Iterators
743(2)
Inserting and Removing Nodes Inside a List
745(2)
Pitfall: Using the Assignment Operator with Dynamic Data Structures
747(3)
Variations on Linked Lists
750(2)
Stacks and Queues
752(19)
Stacks
752(1)
Programming Example: A Stack Class
752(6)
Queues
758(1)
Programming Example: A Queue Class
759(5)
Chapter Summary
764(1)
Answers to Self-Test Exercises
764(3)
Programming Projects
767(4)
Inheritance
771(50)
Inheritance Basics
773(22)
Derived Classes
773(9)
Constructors in Derived Classes
782(2)
Pitfall: Use of Private Member Variables from the Base Class
784(2)
Pitfall: Private Member Functions Are Effectively Not Inherited
786(1)
The protected Qualifier
786(3)
Redefinition of Member Functions
789(2)
Redefining versus Overloading
791(3)
Access to a Redefined Base Function
794(1)
Inheritance Details
795(3)
Functions That Are Not Inherited
795(1)
Assignment Operators and Copy Constructors in Derived Classes
796(1)
Destructors in Derived Classes
797(1)
Polymorphism
798(23)
Late Binding
798(1)
Virtual Functions in C++
799(6)
Virtual Functions and Extended Type Compatibility
805(2)
Pitfall: The Slicing Problem
807(3)
Pitfall: Not Using Virtual Member Functions
810(1)
Pitfall: Attempting to Compile Class Definitions Without Definitions for Every Virtual Member Function
811(1)
Programming Tip: Make Destructors Virtual
811(2)
Chapter Summary
813(1)
Answers to Self-Test Exercises
813(4)
Programming Projects
817(4)
Exception Handling
821(30)
Exception-Handling Basics
823(20)
A Toy Example of Exception Handling
823(9)
Defining Your Own Exception Classes
832(1)
Multiple Throws and Catches
832(1)
Pitfall: Catch the More Specific Exception First
832(5)
Programming Tip: Exception Classes Can Be Trivial
837(1)
Throwing an Exception in a Function
837(1)
Exception Specification
838(4)
Pitfall: Exception Specification in Derived Classes
842(1)
Programming Techniques for Exception Handling
843(8)
When to Throw an Exception
843(1)
Pitfall: Uncaught Exceptions
844(1)
Pitfall: Nested try-catch Blocks
845(1)
Pitfall: Overuse of Exceptions
845(1)
Exception Class Hierarchies
845(1)
Testing for Available Memory
845(1)
Rethrowing an Exception
846(1)
Chapter Summary
847(1)
Answers to Self-Test Exercises
847(1)
Programming Projects
848(3)
Standard Template Library
851(50)
Iterators
853(14)
Using Declarations
853(1)
Iterator Basics
854(5)
Kinds of Iterators
859(4)
Constant and Mutable Iterators
863(1)
Reverse Iterators
864(1)
Pitfall: Compiler Problems
865(1)
Other Kinds of Iterators
865(2)
Containers
867(15)
Sequential Containers
867(5)
Pitfall: Iterators and Removing Elements
872(1)
Programming Tip: Type Definitions in Containers
873(1)
Container Adapters stack and queue
873(1)
Associative Containers set and map
874(8)
Efficiency
882(1)
Generic Algorithms
882(19)
Running Times and Big-O Notation
883(4)
Container Access Running Times
887(1)
Nonmodifying Sequence Algorithms
887(5)
Container Modifying Algorithms
892(1)
Set Algorithms
892(3)
Sorting Algorithms
895(1)
Chapter Summary
896(1)
Answers to Self-Test Exercises
896(2)
Programming Projects
898(3)
Appendix 1 C++ Keywords 901(1)
Appendix 2 Precedence of Operators 902(2)
Appendix 3 The ASCII Character Set 904(1)
Appendix 4 Some Library Functions 905(7)
Appendix 5 The assert Statement 912(1)
Appendix 6 Inline Functions 913(1)
Appendix 7 Overloading the Array Index Square Brackets 914(2)
Appendix 8 The this Pointer 916(2)
Appendix 9 Overloading Operators as Member Operators 918(3)
Index 921

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Rewards Program