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.

9780201703900

Problem Solving With C++: The Object of Programming

by
  • ISBN13:

    9780201703900

  • ISBN10:

    0201703904

  • Edition: 3rd
  • Format: Paperback
  • Copyright: 2000-11-01
  • Publisher: Pearson College Div
  • 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: $81.00

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(38)
Computer Systems
2(11)
Hardware
2(5)
Software
7(1)
High-Level Languages
8(1)
Compilers
9(2)
Self-Test Exercises
11(1)
History Note
12(1)
Programming and Problem-Solving
13(6)
Algorithms
14(1)
Program Design
15(2)
The Software Life Cycle
17(1)
Self-Test Exercises
18(1)
Introduction to C++
19(11)
Origins of the C++ Language
19(1)
A Sample C++ Program
20(4)
Pitfall---Using the Wrong Slash in \n
24(1)
Programming Tip---Input and Output Syntax
24(1)
Pitfall---Putting a Space before the include File Name
24(1)
Layout of a Simple C++ Program
25(2)
Compiling and Running a C++ Program
27(1)
Programming Tip---Getting Your Program to Run
28(1)
Self-Test Exercises
29(1)
Testing and Debugging
30(9)
Kinds of Program Errors
31(1)
Pitfall---Assuming Your Program Is Correct
32(1)
Self-Test Exercises
32(1)
Chapter Summary
33(1)
Answers to Self-Test Exercises
34(2)
Programming Projects
36(3)
C++ Basics
39(68)
Variables and Assignments
40(10)
Variables
40(1)
Names: Identifiers
41(3)
Variable Declarations
44(2)
Assignment Statements
46(2)
Pitfall---Uninitialized Variables
48(1)
Programming Tip---Use Meaningful Names
49(1)
Self-Test Exercises
49(1)
Input and Output
50(10)
Output Using cout
50(2)
Include Directives and Namespaces
52(1)
Escape Sequences
53(2)
Programming Tip---End Each Program with a \n or endl
55(1)
Formatting for Numbers with a Decimal Point
55(2)
Input Using cin
57(1)
Designing Input and Output
58(1)
Programming Tip---Line Breaks in I/O
59(1)
Self-Test Exercises
59(1)
Data Types and Expressions
60(13)
The Types int and double
60(2)
Other Number Types
62(2)
The Type Char
64(1)
The Type bool
65(1)
Type Compatibilities
65(2)
Arithmetic Operators and Expressions
67(3)
Pitfall---Whole Numbers in Division
70(1)
Self-Test Exercises
71(1)
More Assignment Statements
72(1)
Simple Flow of Control
73(20)
A Simple Branching Mechanism
73(6)
Pitfall---Strings of Inequalities
79(1)
Pitfall---Using = in place of ==
79(2)
Compound Statements
81(1)
Self-Test Exercises
82(1)
Simple Loop Mechanisms
83(4)
Increment and Decrement Operators
87(2)
Programming Example---Charge Card Balance
89(1)
Pitfall---Infinite Loops
90(2)
Self-Test Exercises
92(1)
Program Style
93(14)
Indenting
93(1)
Comments
94(1)
Naming Constants
95(3)
Self-Test Exercises
98(1)
Chapter Summary
98(1)
Answers to Self-Test Exercises
99(5)
Programming Projects
104(3)
Procedural Abstraction and Functions That Return a Value
107(66)
Top-Down Design
108(1)
Predefined Functions
109(10)
Using Predefined Functions
109(6)
Pitfall---Problems with Library Names
115(1)
Type Changing Functions
115(3)
Pitfall---Integer Division Drops the Fractional Part
118(1)
Self-Test Exercises
118(1)
Programmer-Defined Functions
119(11)
Function Definitions
119(5)
Alternate Form for Function Prototypes
124(2)
Pitfall---Arguments in the Wrong Order
126(2)
Function Definition-Syntax Summary
128(1)
More About Placement of Function Definitions
129(1)
Self-Test Exercises
130(1)
Procedural Abstraction
130(12)
The Black Box Analogy
131(2)
Programming Tip---Choosing Formal Parameter Names
133(1)
Case Study---Buying Pizza
134(7)
Programming Tip---Use Pseudocode
141(1)
Self-Test Exercises
141(1)
Local Variables
142(13)
The Small Program Analogy
142(3)
Programming Example---Experimental Pea Patch
145(1)
Global Constants and Global Variables
145(3)
Call-by-Value Formal Parameters Are Local Variables
148(3)
Namespaces Revisited
151(2)
Self-Test Exercises
153(1)
Programming Example---The Factorial Function
154(1)
Overloading Function Names
155(18)
Introduction to Overloading
156(3)
Programming Example---Revised Pizza-Buying Program
159(1)
Automatic Type Conversion
160(3)
Self-Test Exercises
163(1)
Chapter Summary
164(1)
Answers to Self-Test Exercises
165(3)
Programming Projects
168(5)
Functions for All Subtasks
173(48)
void-Functions
174(8)
Definitions of void-Functions
174(3)
Programming Example---Converting Temperatures from Fahrenheit to Celsius
177(1)
return-Statements in void-Functions
177(3)
Self-Test Exercises
180(2)
Call-by-Reference Parameters
182(14)
A First View of Call-by-Reference
182(3)
Call-by-Reference in Detail
185(2)
Programming Example---The Swap_values Function
187(3)
Mixed Parameter Lists
190(1)
Programming Tip---What Kind of Parameter to Use
191(2)
Pitfall---Inadvertent Local Variables
193(2)
Self-Test Exercises
195(1)
Using Procedural Abstraction
196(10)
Functions Calling Functions
196(3)
Preconditions and Postconditions
199(1)
Case Study---Supermarket Pricing
200(3)
Self-Test Exercises
203(3)
Testing and Debugging Functions
206(15)
Stubs and Drivers
206(3)
Self-Test Exercises
209(3)
Chapter Summary
212(1)
Answers to Self-Test Exercises
213(3)
Programming Projects
216(5)
I/O Streams as an Introduction to Objects and Classes
221(78)
Streams and Basic File I/O
222(16)
Why Use Files for I/O?
223(1)
File I/O
224(3)
Introduction to Classes and Objects
227(4)
Programming Tip---Check that a File Was Opened Successfully
231(3)
Techniques for File I/O
234(2)
Self-Test Exercises
236(1)
File Names as Input (Optional)
236(2)
Tools for Stream I/O
238(17)
Formatting Output with Stream Functions
241(3)
Manipulators
244(2)
Self-Test Exercises
246(2)
Streams as Arguments to Functions
248(1)
Programming Tip---Checking for the End of a File
248(4)
A Note on Namespaces
252(2)
Programming Example---Cleaning Up a File Format
254(1)
Self-Test Exercises
254(1)
Character I/O
255(20)
The Member Functions get and put
256(3)
The putback Member Function (Optional)
259(1)
Programming Example---Checking Input
260(1)
Pitfall---Unexpected ` \n' in Input
261(3)
The eof Member Function
264(2)
Self-Test Exercises
266(2)
Programming Example---Editing a Text File
268(1)
Predefined Character Functions
269(3)
Pitfall---toupper and to lower Return int Values
272(2)
Self-Test Exercises
274(1)
Inheritance
275(24)
Inheritance Among Stream Classes
275(4)
Programming Example---Another new_line Function
279(1)
Default Arguments for Functions (Optional)
280(1)
Self-Test Exercises
281(2)
Chapter Summary
283(2)
Answers to Self-Test Exercises
285(6)
Programming Projects
291(8)
Defining Classes and Abstract Data Types
299(66)
Structures
300(13)
Structures for Diverse Data
300(6)
Pitfall---Forgetting a Semicolon in a Structure Definition
306(1)
Structures as Function Arguments
307(2)
Programming Tip---Use Hierarchical Structures
309(1)
Initializing Structures
310(1)
Self-Test Exercises
310(3)
Classes
313(32)
Defining Classes and Member Functions
313(4)
Self-Test Exercises
317(2)
Public and Private Members
319(6)
Programming Tip---Make All Member Variables Private
325(1)
Programming Tip---Define Accessor Functions
325(2)
Programming Tip---Use the Assignment Operator with Objects
327(1)
Self-Test Exercises
327(2)
Programming Example---Bank Account Class---Version 1
329(5)
Summary of Some Properties of Classes
334(1)
Self-Test Exercises
335(1)
Constructors for Initialization
336(5)
Programming Tip---Always Include a Default Constructor
341(2)
Pitfall---Constructors with No Arguments
343(1)
Self-Test Exercises
344(1)
Abstract Data Types
345(20)
Classes to Produce ADTs
345(4)
Programming Example---Alternative Implementation of a Class
349(5)
Self-Test Exercises
354(1)
Chapter Summary
354(1)
Answers to Self-Test Exercises
355(5)
Programming Projects
360(5)
More Flow of Control
365(76)
Using Boolean Expressions
366(9)
Evaluating Boolean Expressions
366(5)
Pitfall---Boolean Expressions Convert to into Values
371(2)
Self-Test Exercises
373(1)
Functions That Return a Boolean Value
373(1)
Self-Test Exercises
374(1)
Enumeration Types (Optional)
374(1)
Multiway Branches
375(22)
Nested Statements
376(1)
Programming Tip---Use Braces in Nested Statements
376(3)
Multiway if-else-Statements
379(1)
Programming Example---State Income Tax
380(3)
Self-Test Exercises
383(2)
The switch-Statement
385(4)
Pitfall---Forgetting a break in a switch-Statement
389(1)
Using switch-Statements for Menus
389(3)
Programming Tip---Use Function Calls in Branching Statements
392(1)
Blocks
392(3)
Pitfall---Inadvertent Local Variables
395(1)
Self-Test Exercises
396(1)
More About C++ Loop Statements
397(17)
The while-Statements Reviewed
398(1)
Increment and Decrement Operators Revisited
398(4)
Self-Test Exercises
402(1)
The for-Statement
403(4)
Pitfall---Extra Semicolon in a for-Statement
407(2)
What Kind of Loop to Use
409(1)
Self-Test Exercises
410(1)
Pitfall---Uninitialized Variables and Infinite Loops
411(1)
The break-Statement
412(1)
Pitfall---The break-Statement in Nested Loops
412(1)
Self-Test Exercises
412(2)
Designing Loops
414(27)
Loops for Sums and Products
414(2)
Ending a Loop
416(3)
Nested Loops
419(5)
Self-Test Exercises
424(1)
Debugging Loops
424(3)
Self-Test Exercises
427(1)
Chapter Summary
428(1)
Answers to Self-Test Exercises
429(7)
Programming Projects
436(5)
Tools for Defining ADTs
441(88)
Defining ADT Operations
442(44)
Programming Example---An Equality Function
442(4)
Self-Test Exercise
446(1)
Friend Functions
446(1)
Programming Tip---Define Both Accessor Functions and Friend Functions
447(3)
Programming Tip---Use Both Member and Nonmember Functions
450(1)
Pitfall---Compilers without Friends
451(1)
Programming Example---Money ADT (Version 1)
451(7)
Implementation of digit_to_int (Optional)
458(1)
Pitfall---Leading Zeros in Number Constants
459(1)
Self-Test Exercises
460(1)
The const Parameter Modifier
461(3)
Pitfall---Inconsistent Use of const
464(1)
Self-Test Exercises
464(2)
Overloading Operators
466(4)
Self-Test Exercises
470(1)
Constructors for Automatic Type Conversion
470(3)
Self-Test Exercises
473(1)
Overloading Unary Operators
473(1)
Overloading ≫ and ≪
474(11)
Self-Test Exercise
485(1)
Separate Compilation
486(18)
ADTs Reviewed
486(1)
Case Study---Digital Time---An ADT Compiled Separately
487(10)
Programming Tip---Hiding the Helping Functions
497(1)
Using # ifndef
498(3)
Programming Tip---Choosing ADT Operations
501(1)
Programming Tip---Defining Other Libraries
502(1)
Self-Test Exercises
503(1)
Namespaces
504(25)
Namespaces and Using Directives
504(2)
Creating a Namespace
506(3)
Self-Test Exercises
509(1)
Qualifying Names
509(1)
Self-Test Exercises
510(1)
Programming Example---A Class Definition in a Namespace
511(2)
Chapter Summary
513(1)
Answers to Self-Test Exercises
514(9)
Programming Projects
523(6)
Arrays
529(76)
Introduction to Arrays
530(11)
Declaring and Referencing Arrays
531(3)
Programming Tip---Use for-Loops with Arrays
534(1)
Arrays in Memory
535(1)
Pitfall---Array Index Out of Range
536(2)
Initializing Arrays
538(1)
Self-Test Exercises
539(2)
Arrays in Functions
541(12)
Indexed Variables as Function Arguments
541(1)
Pitfall---Array Indexes Always Start with Zero
542(1)
Programming Tip---Use a Defined Constant for the Size of an Array
542(2)
Self-Test Exercises
544(1)
Entire Arrays as Function Arguments
544(4)
The const Parameter Modifier
548(3)
Self-Test Exercises
551(2)
Programming with Arrays
553(25)
Case Study---Production Graph
553(10)
Partially Filled Arrays
563(4)
Programming Example---Searching on Array
567(3)
Programming Tip---Do Not Skimp on Formal Parameters
570(3)
Programming Example---Sorting on Array
573(2)
Self-Test Exercises
575(3)
Arrays and Classes
578(27)
Arrays of Classes
578(2)
Self-Test Exercises
580(1)
Arrays as Class Members
580(4)
Programming Example---A Class for a partially Filled Array
584(3)
Self-Test Exercises
587(1)
Chapter Summary
588(1)
Answers to Self-Test Exercises
589(7)
Programming Projects
596(9)
Strings and Multidimensional Arrays
605(72)
String Basics
606(22)
Cstring Values and Cstring Variables
606(5)
Pitfall---Using = and == with cstrings
611(1)
Predefined Cstring Functions
612(2)
Pitfall---Dangers in Using Functions from <cstring>
614(1)
Self-Test Exercises
614(2)
Defining Cstring Functions
616(3)
Cstring Input and Output
619(2)
Cstring-to-Number Conversions and Robust Input
621(6)
Self-Test Exercises
627(1)
Multidimensional Arrays
628(9)
Multidimensional Array Basics
628(2)
Programming Example---Two-Dimensional Grading Program
630(5)
Arrays of Cstrings
635(1)
Self-Test Exercises
635(2)
The C++ Standard string Class
637(40)
Interface for the Standard Class string
638(5)
Pitfall---Code That Depends on Order of Evaluation Is Illegal
643(1)
Programming Tip---The Ignore Member Function
643(1)
Pitfall---Mixing cin ≫ variable; and getline Can Lose Input
644(1)
Programming Example---Palindrome Testing
644(8)
Arrays of strings Revisited
652(1)
Self-Test Exercises
652(1)
Namespaces Revisited
652(5)
Chapter Summary
657(1)
Answers to Self-Test Exercises
658(7)
Programming Projects
665(12)
Pointers and Dynamic Arrays
677(46)
Pointers
678(14)
Pointer Variables
679(4)
Self-Test Exercises
683(4)
Basic Memory Management
687(2)
Pitfall---Dangling Pointers
689(1)
Static Variables and Automatic Variables
689(1)
Programming Tip---Define Pointer Types
690(2)
Self-Test Exercises
692(1)
Dynamic Arrays
692(8)
Array Variables and Pointer Variables
692(2)
Creating and Using Dynamic Arrays
694(5)
Self-Test Exercises
699(1)
Pointer Arithmetic (Optional)
699(1)
Classes and Dynamic Arrays
700(23)
Programming Example---A String Variable Class
701(6)
Destructors
707(1)
Pitfall---Pointers as Call-by-Value Parameters
708(2)
Copy Constructors
710(5)
Self-Test Exercises
715(1)
Overloading the Assignment Operator
715(3)
Self-Test Exercise
718(1)
Chapter Summary
719(1)
Answers to Self-Test Exercises
719(3)
Programming Projects
722(1)
Recursion
723(48)
Recursive Functions for Tasks
725(15)
Case Study---Vertical Numbers
725(8)
A Closer Look at Recursion
733(1)
Pitfall---Infinite Recursion
734(1)
Self-Test Exercises
735(1)
Stacks for Recursion
736(2)
Pitfall---Stack Overflow
738(1)
Recursion versus Iteration
738(1)
Self-Test Exercises
739(1)
Recursive Functions for Values
740(6)
General Form for a Recursive Function That Returns a Value
740(1)
Programming Example---Another Powers Function
740(4)
Self-Test Exercises
744(2)
Thinking Recursively
746(25)
Recursive Design Techniques
746(1)
Case Study---Binary Search---An Example of Recursive Thinking
747(10)
Programming Example---A Recursive Member Function
757(4)
Self-Test Exercises
761(1)
Chapter Summary
761(1)
Answers to Self-Test Exercises
761(6)
Programming Projects
767(4)
Templates for More Abstraction
771(30)
Templates for Algorithm Abstraction
772(12)
Templates for Functions
775(2)
Pitfall---Compiler Complications
777(1)
Self-Test Exercises
778(1)
Programming Example---A Generic Sorting Function
779(5)
Programming Tip---How to Define Templates
784(1)
Self-Test Exercise
784(1)
Templates for Data Abstraction
784(17)
Syntax for Class Templates
785(3)
Programming Example---An Array Class
788(6)
Self-Test Exercises
794(1)
Chapter Summary
795(1)
Answers to Self-Test Exercises
795(3)
Programming Projects
798(3)
Pointers and Linked Lists
801(36)
Nodes and Linked Lists
802(21)
Nodes
802(4)
Self-Test Exercises
806(2)
Linked Lists
808(1)
Inserting a Node at the Head of a List
809(4)
Pitfall---Losing Nodes
813(1)
Searching a Linked List
813(4)
Inserting and Removing Nodes Inside a List
817(5)
Pitfall---Using the Assignment Operator with Dynamic Data Structures
822(1)
Self-Test Exercises
822(1)
A Linked List Application
823(14)
Stacks
824(1)
Programming Example---A Stack ADT
824(6)
Self-Test Exercises
830(1)
Chapter Summary
830(1)
Answers to Self-Test Exercises
831(2)
Programming Projects
833(4)
Inheritance
837(42)
Inheritance Basics
838(23)
Derived Classes
839(8)
Constructor Base Initialization List
847(3)
Constructors in Derived Classes
850(3)
The protected Qualifier
853(1)
Redefinition of Member Functions
854(5)
Redefining versus Overloading
859(1)
Self-Test Exercises
860(1)
Polymorphism
861(18)
Late Binding
861(1)
Virtual Functions in C++
862(6)
Self-Test Exercises
868(1)
Virtual Functions and Extended Type Compatibility
868(3)
Pitfall---The Slicing Problem
871(1)
Pitfall---Not Using Virtual Member Functions
871(3)
Pitfall---Attempting to Compile Class Definitions without Definitions for Every Virtual Member Function
874(1)
Self-Test Exercises
875(1)
Chapter Summary
875(1)
Answers to Self-Test Exercises
875(2)
Programming Projects
877(2)
Exception Handling
879(32)
Exception-Handling Basics
881(22)
A Toy Example of Exception Handling
881(8)
Self-Test Exercises
889(2)
Defining Your Own Exception Classes
891(1)
Multiple Throws and Catches
891(2)
Pitfall---Catch the More Specific Exception First
893(4)
Programming Tip---Exception Classes Can Be Trivial
897(1)
Throwing an Exception in a Function
898(4)
Pitfall---Throw List in Derived Classes
902(1)
Self-Test Exercises
902(1)
Programming Techniques for Exception Handling
903(8)
When to Throw an Exception
903(2)
Pitfall---Uncaught Exceptions
905(1)
Pitfall---Nested try-catch-Blocks
905(1)
Pitfall---Overuse of Exceptions
905(1)
Exception Class Hierarchies
906(1)
Testing for Available Memory
906(1)
Rethrowing an Exception
907(1)
Self-Test Exercises
907(1)
Chapter Summary
907(1)
Answers to Self-Test Exercises
907(2)
Programming Projects
909(2)
Appendix 1 C++ Keywords 911(1)
Appendix 2 Precedence of Operators 912(2)
Appendix 3 The ASCII Character Set 914(1)
Appendix 4 Some Library Functions 915(8)
Arithmetic Functions
915(1)
Input and Output Member Functions
916(2)
Character Functions
918(1)
String Functions
919(2)
Random Number Generator
921(1)
Trigonometric Functions
922(1)
Appendix 5 The assert-Statement 923(2)
Appendix 6 Inline Functions 925(1)
Appendix 7 Constructor Initialization Section 926(2)
Appendix 8 Overloading the Array Index Square Brackets 928(2)
Appendix 9 The this Pointer 930(3)
Appendix 10 Simulating the bool Type 933(1)
Appendix 11 Old and New Header Files 934(1)
Appendix 12 Overloading Operators as Member Operator 935(2)
Annotated Bibliography for C++ Language and Library Issues 937(4)
Index 941

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