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.

9780672327117

Sams Teach Yourself C++ in 21 Days

by ;
  • ISBN13:

    9780672327117

  • ISBN10:

    0672327112

  • Edition: 5th
  • Format: Paperback
  • Copyright: 2005-01-01
  • Publisher: Sams
  • 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: $44.99

Summary

Explains the fundamentals of C++ and how to use it to build object-oriented programs, add functionality, debug programs, learn exception and errorhandling techniques, and make code ANSI compliant.

Table of Contents

Introduction 1(1)
Who Should Read This Book
1(1)
Conventions Used in This Book
1(1)
Sample Code for This Book
2(1)
Week 1 At a Glance
3(216)
A Note to C Programmers
3(1)
Where You Are Going
3(2)
Getting Started
5(20)
A Brief History of C++
5(6)
The Need for Solving Problems
7(1)
Procedural, Structured, and Object-Oriented Programming
8(1)
Object-Oriented Programming (OOP)
9(1)
C++ and Object-Oriented Programming
9(2)
How C++ Evolved
11(1)
Should I Learn C First?
11(1)
C++, Java, and C#
12(1)
Microsoft's Managed Extensions to C++
12(1)
The ANSI Standard
12(1)
Preparing to Program
13(1)
Your Development Environment
14(1)
The Process of Creating the Program
15(1)
Creating an Object File with the Compiler
15(1)
Creating an Executable File with the Linker
15(1)
The Development Cycle
15(2)
Hello.cpp---Your First C++ Program
17(2)
Getting Started with Your Compiler
19(1)
Building the Hello World Project
19(1)
Compile Errors
20(1)
Summary
21(1)
Q&A
21(1)
Workshop
22(3)
Quiz
22(1)
Exercises
23(2)
The Anatomy of a C++ Program
25(16)
A Simple Program
25(3)
A Brief Look at cout
28(2)
Using the Standard Namespace
30(2)
Commenting Your Programs
32(3)
Types of Comments
33(1)
Using Comments
33(1)
A Final Word of Caution About Comments
34(1)
Functions
35(3)
Using Functions
36(2)
Methods Versus Functions
38(1)
Summary
38(1)
Q&A
38(1)
Workshop
39(2)
Quiz
39(1)
Exercises
39(2)
Working with Variables and Constants
41(26)
What Is a Variable?
41(6)
Storing Data in Memory
42(1)
Setting Aside Memory
42(1)
Size of Integers
43(2)
signed and unsigned
45(1)
Fundamental Variable Types
45(2)
Defining a Variable
47(3)
Case Sensitivity
48(1)
Naming Conventions
48(1)
Keywords
49(1)
Creating More Than One Variable at a Time
50(1)
Assigning Values to Your Variables
50(2)
Creating Aliases with typedef
52(1)
When to Use short and When to Use long
53(3)
Wrapping Around an unsigned Integer
54(1)
Wrapping Around a signed Integer
55(1)
Working with Characters
56(3)
Characters and Numbers
57(1)
Special Printing Characters
58(1)
Constants
59(2)
Literal Constants
59(1)
Symbolic Constants
59(2)
Enumerated Constants
61(2)
Summary
63(1)
Q&A
64(1)
Workshop
65(2)
Quiz
65(1)
Exercises
66(1)
Creating Expressions and Statements
67(32)
Starting with Statements
68(1)
Using Whitespace
68(1)
Blocks and Compound Statements
68(1)
Expressions
69(1)
Working with Operators
70(3)
Assignment Operators
71(1)
Mathematical Operators
71(2)
Combining the Assignment and Mathematical Operators
73(1)
Incrementing and Decrementing
74(3)
Prefixing Versus Postfixing
75(2)
Understanding Operator Precedence
77(1)
Nesting Parentheses
78(1)
The Nature of Truth
79(1)
Evaluating with the Relational Operators
79(1)
The if Statement
80(8)
Indentation Styles
83(1)
The else Statement
84(2)
Advanced if Statements
86(2)
Using Braces in Nested if Statements
88(3)
Using the Logical Operators
91(1)
The Logical and Operator
91(1)
The Logical or Operator
91(1)
The Logical not Operator
92(1)
Short Circuit Evaluation
92(1)
Relational Precedence
92(1)
More About Truth and Falsehood
93(1)
The Conditional (Ternary) Operator
94(1)
Summary
95(1)
Q&A
96(1)
Workshop
96(3)
Quiz
97(1)
Exercises
97(2)
Organizing into Functions
99(38)
What Is a Function?
100(1)
Return Values, Parameters, and Arguments
100(1)
Declaring and Defining Functions
101(4)
Function Prototypes
102(1)
Defining the Function
103(2)
Execution of Functions
105(1)
Determining Variable Scope
105(4)
Local Variables
105(2)
Local Variables Within Blocks
107(2)
Parameters Are Local Variables
109(3)
Global Variables
110(2)
Global Variables: A Word of Caution
112(1)
Considerations for Creating Function Statements
112(1)
More About Function Arguments
113(1)
More About Return Values
114(2)
Default Parameters
116(2)
Overloading Functions
118(3)
Special Topics About Functions
121(8)
Inline Functions
122(2)
Recursion
124(5)
How Functions Work---A Peek Under the Hood
129(4)
Levels of Abstraction
129(4)
Summary
133(1)
Q&A
134(1)
Workshop
134(3)
Quiz
135(1)
Exercises
135(2)
Understanding Object-Oriented Programming
137(38)
Is C++ Object-Oriented?
137(2)
Creating New Types
139(1)
Introducing Classes and Members
140(2)
Declaring a Class
141(1)
A Word on Naming Conventions
141(1)
Defining an Object
142(1)
Classes Versus Objects
142(1)
Accessing Class Members
142(2)
Assigning to Objects, Not to Classes
143(1)
If You Don't Declare It, Your Class Won't Have It
143(1)
Private Versus Public Access
144(6)
Making Member Data Private
146(4)
Implementing Class Methods
150(3)
Adding Constructors and Destructors
153(4)
Getting a Default Constructor and Destructor
153(1)
Using the Default Constructor
154(3)
Including const Member Functions
157(1)
Interface Versus Implementation
158(3)
Where to Put Class Declarations and Method Definitions
161(1)
Inline Implementation
162(3)
Classes with Other Classes as Member Data
165(4)
Exploring Structures
169(1)
Summary
170(1)
Q&A
171(1)
Workshop
172(3)
Quiz
172(1)
Exercises
173(2)
More on Program Flow
175(44)
Looping
175(2)
The Roots of Looping: goto
176(1)
Why goto Is Shunned
176(1)
Using while Loops
177(7)
Exploring More Complicated while Statements
179(1)
Introducing continue and break
180(3)
Examining while (true) Loops
183(1)
Implementing do. . .while Loops
184(2)
Using do. . .while
186(1)
Looping with the for Statement
187(9)
Advanced for Loops
190(2)
Empty for Loops
192(1)
Nesting Loops
193(2)
Scoping in for Loops
195(1)
Summing Up Loops
196(2)
Controlling Flow with switch Statements
198(7)
Using a switch Statement with a Menu
201(4)
Summary
205(1)
Q&A
205(1)
Workshop
206(3)
Quiz
206(1)
Exercises
206(3)
In Review
209(10)
Week 2 At a Glance
219(284)
Where You Are Going
219(2)
Understanding Pointers
221(34)
What Is a Pointer?
222(10)
A Bit About Memory
222(1)
Getting a Variable's Memory Address
222(2)
Storing a Variable's Address in a Pointer
224(1)
Pointer Names
224(1)
Getting the Value from a Variable
225(1)
Dereferencing with the Indirection Operator
226(1)
Pointers, Addresses, and Variables
227(1)
Manipulating Data by Using Pointers
228(1)
Examining the Address
229(3)
Why Would You Use Pointers?
232(1)
The Stack and the Free Store (Heap)
232(5)
Allocating Space with the new Keyword
234(1)
Putting Memory Back: The delete Keyword
235(2)
Another Look at Memory Leaks
237(1)
Creating Objects on the Free Store
238(1)
Deleting Objects from the Free Store
238(1)
Accessing Data Members
239(2)
Creating Member Data on the Free Store
241(2)
The this Pointer
243(2)
Stray, Wild, or Dangling Pointers
245(3)
Using const Pointers
248(3)
const Pointers and const Member Functions
249(2)
Using a const this Pointers
251(1)
Summary
251(1)
Q&A
252(1)
Workshop
252(3)
Quiz
252(1)
Exercises
253(2)
Exploiting References
255(34)
What Is a Reference?
255(2)
Using the Address-Of Operator (&) on References
257(3)
Attempting to Reassign References (Not!)
259(1)
Referencing Objects
260(2)
Null Pointers and Null References
262(1)
Passing Function Arguments by Reference
262(5)
Making swap() Work with Pointers
264(1)
Implementing swap () with References
265(2)
Understanding Function Headers and Prototypes
267(1)
Returning Multiple Values
268(3)
Returning Values by Reference
270(1)
Passing by Reference for Efficiency
271(8)
Passing a const Pointer
274(3)
References as an Alternative
277(2)
Knowing When to Use References Versus Pointers
279(1)
Mixing References and Pointers
280(1)
Returning Out-of-Scope Object References
281(4)
Returning a Reference to an Object on the Heap
283(2)
Pointer, Pointer, Who Has the Pointer?
285(1)
Summary
286(1)
Q&A
286(1)
Workshop
287(2)
Quiz
287(1)
Exercises
287(2)
Working with Advanced Functions
289(40)
Overloaded Member Functions
289(3)
Using Default Values
292(2)
Choosing Between Default Values and Overloaded Functions
294(1)
The Default Constructor
294(1)
Overloading Constructors
295(2)
Initializing Objects
297(1)
The Copy Constructor
298(4)
Operator Overloading
302(18)
Writing an Increment Function
303(1)
Overloading the Prefix Operator
304(2)
Returning Types in Overloaded Operator Functions
306(1)
Returning Nameless Temporaries
307(2)
Using the this Pointer
309(2)
Overloading the Postfix Operator
311(1)
Difference Between Prefix and Postfix
311(2)
Overloading Binary Mathematical Operators
313(3)
Issues in Operator Overloading
316(1)
Limitations on Operator Overloading
316(1)
What to Overload
317(1)
The Assignment Operator
317(3)
Handling Data Type Conversion
320(3)
Conversion Operators
323(2)
Summary
325(1)
Q&A
325(1)
Workshop
326(3)
Quiz
326(1)
Exercises
327(2)
Object-Oriented Analysis and Design
329(42)
Building Models
329(1)
Software Design: The Modeling Language
330(1)
Software Design: The Process
331(4)
Waterfall Versus Iterative Development
332(1)
The Process of Iterative Development
333(2)
Step 1: The Conceptualization Phase: Starting with The Vision
335(1)
Step 2: The Analysis Phase: Gathering Requirements
336(14)
Use Cases
336(11)
Application Analysis
347(1)
Systems Analysis
347(1)
Planning Documents
348(1)
Visualizations
349(1)
Artifacts
349(1)
Step 3: The Design Phase
350(16)
What Are the Classes?
350(2)
Transformations
352(1)
Other Transformations
353(1)
Building the Static Model
354(9)
Dynamic Model
363(3)
Steps 4--6: Implementation, Testing, and Rollout?
366(1)
Iterations
367(1)
Summary
367(1)
Q&A
367(1)
Workshop
368(3)
Quiz
368(1)
Exercises
369(2)
Implementing Inheritance
371(36)
What Is Inheritance?
371(5)
Inheritance and Derivation
372(1)
The Animal Kingdom
373(1)
The Syntax of Derivation
374(2)
Private Versus Protected
376(2)
Inheritance with Constructors and Destructors
378(7)
Passing Arguments to Base Constructors
381(4)
Overriding Base Class Functions
385(6)
Hiding the Base Class Method
387(2)
Calling the Base Method
389(2)
Virtual Methods
391(12)
How Virtual Functions Work
395(1)
Trying to Access Methods from a Base Class
396(1)
Slicing
397(2)
Creating Virtual Destructors
399(1)
Virtual Copy Constructors
400(3)
The Cost of Virtual Methods
403(1)
Summary
403(1)
Q&A
404(1)
Workshop
405(2)
Quiz
405(1)
Exercises
405(2)
Managing Arrays and Strings
407(42)
What Is an Array?
407(9)
Accessing Array Elements
408(2)
Writing Past the End of an Array
410(3)
Fence Post Errors
413(1)
Initializing Arrays
413(1)
Declaring Arrays
414(2)
Using Arrays of Objects
416(5)
Declaring Multidimensional Arrays
417(2)
Initializing Multidimensional Arrays
419(2)
Building Arrays of Pointers
421(2)
A Look at Pointer Arithmetic---An Advanced Topic
423(3)
Declaring Arrays on the Free Store
426(6)
A Pointer to an Array Versus an Array of Pointers
426(1)
Pointers and Array Names
427(2)
Deleting Arrays on the Free Store
429(1)
Resizing Arrays at Runtime
429(3)
char Arrays and Strings
432(3)
Using the strcpy ( ) and strncpy ( ) Methods
435(1)
String Classes
435(9)
Linked Lists and Other Structures
444(1)
Creating Array Classes
444(1)
Summary
445(1)
Q&A
445(1)
Workshop
446(3)
Quiz
446(1)
Exercises
447(2)
Polymorphism
449(54)
Problems with Single Inheritance
449(7)
Percolating Upward
452(1)
Casting Down
453(3)
Adding to Two Lists
456(1)
Multiple Inheritance
456(17)
The Parts of a Multiply Inherited Object
460(1)
Constructors in Multiply Inherited Objects
460(3)
Ambiguity Resolution
463(1)
Inheriting from Shared Base Class
464(4)
Virtual Inheritance
468(4)
Problems with Multiple Inheritance
472(1)
Mixins and Capabilities Classes
473(1)
Abstract Data Types
473(13)
Pure Virtual Functions
477(1)
Implementing Pure Virtual Functions
478(4)
Complex Hierarchies of Abstraction
482(4)
Which Classes Are Abstract?
486(1)
Summary
486(1)
Q&A
487(1)
Workshop
488(3)
Quiz
488(1)
Exercises
489(2)
In Review
491(12)
Week 3 At a Glance
503(304)
Where You Are Going
503(2)
Special Classes and Functions
505(32)
Sharing Data Among Objects of the Same Type: Static Member Data
506(5)
Using Static Member Functions
511(3)
Pointers to Functions
514(14)
Why Use Function Pointers?
517(4)
Arrays of Pointers to Functions
521(2)
Passing Pointers to Functions to Other Functions
523(2)
Using typedef with Pointers to Functions
525(3)
Pointers to Member Functions
528(5)
Arrays of Pointers to Member Functions
531(2)
Summary
533(1)
Q&A
533(1)
Workshop
534(3)
Quiz
534(1)
Exercises
534(3)
Advanced Inheritance
537(56)
Aggregation
537(15)
Accessing Members of the Aggregated Class
545(1)
Controlling Access to Aggregated Members
545(1)
Cost of Aggregation
546(3)
Copying by Value
549(3)
Implementation in Terms of Inheritance Versus Aggregation Delegation
552(10)
Using Delegation
553(9)
Private Inheritance
562(9)
Adding Friend Classes
571(9)
Friend Functions
580(1)
Friend Functions and Operator Overloading
580(5)
Overloading the Insertion Operator
585(4)
Summary
589(1)
Q&A
590(1)
Workshop
591(2)
Quiz
591(1)
Exercises
591(2)
Working with Streams
593(44)
Overview of Streams
593(4)
Encapsulation of Data Flow
594(1)
Understanding Buffering
594(3)
Streams and Buffers
597(1)
Standard I/O Objects
597(1)
Redirection of the Standard Streams
598(1)
Input Using cin
599(5)
Inputting Strings
600(1)
String Problems
601(2)
The cin Return Value
603(1)
Other Member Functions of cin
604(9)
Single Character Input
604(3)
Getting Strings from Standard Input
607(3)
Using cin.ignore( )
610(1)
Peeking at and Returning Characters: peek ( ) and putback ( )
611(2)
Outputting with cout
613(7)
Flushing the Output
613(1)
Functions for Doing Output
613(2)
Manipulators, Flags, and Formatting Instructions
615(5)
Streams Versus the printf ( ) Function
620(3)
File Input and Output
623(1)
Using the of stream
624(5)
Condition States
624(1)
Opening Files for Input and Output
624(2)
Changing the Default Behavior of of stream on Open
626(3)
Binary Versus Text Files
629(2)
Command-line Processing
631(3)
Summary
634(1)
Q&A
635(1)
Workshop
636(1)
Quiz
636(1)
Exercises
636(1)
Creating and Using Namespaces
637(22)
Getting Started
637(1)
Resolving Functions and Classes by Name
638(5)
Visibility of Variables
640(1)
Linkage
641(1)
Static Global Variables
642(1)
Creating a Namespace
643(3)
Declaring and Defining Types
644(1)
Defining Functions Outside a Namespace
645(1)
Adding New Members
645(1)
Nesting Namespaces
646(1)
Using a Namespace
646(2)
The using Keyword
648(4)
The using Directive
648(2)
The using Declaration
650(2)
The Namespace Alias
652(1)
The Unnamed Namespace
652(2)
The Standard Namespace std
654(1)
Summary
655(1)
Q&A
656(1)
Workshop
656(3)
Quiz
656(1)
Exercises
657(2)
Templates
659(56)
What Are Templates?
659(2)
Building a Template Definition
661(8)
Using the Name
664(1)
Implementing the Template
665(4)
Passing Instantiated Template Objects to Functions
669(1)
Templates and Friends
670(8)
Nontemplate Friend Classes and Functions
670(4)
General Template Friend Class or Function
674(4)
Using Template Items
678(15)
Using Specialized Functions
683(6)
Static Members and Templates
689(4)
The Standard Template Library
693(18)
Using Containers
693(1)
Understanding Sequence Containers
694(10)
Understanding Associative Containers
704(4)
Working with the Algorithm Classes
708(3)
Summary
711(1)
Q&A
712(1)
Workshop
713(2)
Quiz
713(1)
Exercises
713(2)
Handling Errors and Exceptions
715(36)
Bugs, Errors, Mistakes, and Code Rot
716(2)
Exceptional Circumstances
717(1)
The Idea Behind Exceptions
718(10)
The Parts of Exception Handling
719(3)
Causing Your Own Exceptions
722(2)
Creating an Exception Class
724(4)
Placing try Blocks and catch Blocks
728(1)
How Catching Exceptions Work
728(7)
Using More Than One catch Specification
729(3)
Exception Hierarchies
732(3)
Data in Exceptions and Naming Exception Objects
735(7)
Exceptions and Templates
742(3)
Exceptions Without Errors
745(1)
A Word About Code Rot
746(1)
Bugs and Debugging
746(2)
Breakpoints
747(1)
Watch Points
747(1)
Examining Memory
747(1)
Assembler
747(1)
Summary
748(1)
Q&A
748(1)
Workshop
749(2)
Quiz
749(1)
Exercises
750(1)
What's Next
751(56)
The Preprocessor and the Compiler
752(1)
The #define Preprocessor Directive
752(3)
Using #define for Constants
753(1)
Using #define for Tests
753(1)
The #else Precompiler Command
754(1)
Inclusion and Inclusion Guards
755(1)
Macro Functions
756(3)
Why All the Parentheses?
757(2)
String Manipulation
759(1)
Stringizing
759(1)
Concatenation
759(1)
Predefined Macros
760(1)
The assert () Macro
761(10)
Debugging with assert ()
762(1)
Using assert () Versus Exceptions
763(1)
Side Effects
763(1)
Class Invariants
764(5)
Printing Interim Values
769(2)
Inline Functions
771(2)
Bit Twiddling
773(6)
Operator AND
773(1)
Operator OR
774(1)
Operator Exclusive OR
774(1)
The Complement Operator
774(1)
Setting Bits
774(1)
Clearing Bits
774(1)
Flipping Bits
775(1)
Bit Fields
775(4)
Programming Style
779(5)
Indenting
779(1)
Braces
779(1)
Long Lines and Function Length
780(1)
Structuring switch Statements
780(1)
Program Text
780(1)
Naming Identifiers
781(1)
Spelling and Capitalization of Names
782(1)
Comments
782(1)
Setting Up Access
783(1)
Class Definitions
783(1)
include Files
784(1)
Using assert ()
784(1)
Making Items Constant with const
784(1)
Next Steps in Your C++ Development
784(2)
Where to Get Help and Advice
785(1)
Related C++ Topics: Managed C++, C#, and Microsoft's .NET
785(1)
Staying in Touch
786(1)
Summary
786(1)
Q&A
787(1)
Workshop
788(3)
Quiz
788(1)
Exercises
789(2)
In Review
791(16)
A Working with Numbers: Binary and Hexadecimal
807(10)
Using Other Bases
808(1)
Converting to Different Bases
809(4)
Binary
810(1)
Why Base 2?
811(1)
Bits, Bytes, and Nybbles
812(1)
What's a KB?
812(1)
Binary Numbers
812(1)
Hexadecimal
813(4)
B C++ Keywords
817(2)
C Operator Precedence
819(2)
D Answers
821(54)
Day 1
821(1)
Quiz
821(1)
Exercises
822(1)
Day 2
822(2)
Quiz
822(1)
Exercises
823(1)
Day 3
824(1)
Quiz
824(1)
Exercises
825(1)
Day 4
825(1)
Quiz
825(1)
Exercises
826(1)
Day 5
826(3)
Quiz
826(1)
Exercises
827(2)
Day 6
829(3)
Quiz
829(1)
Exercises
829(3)
Day 7
832(1)
Quiz
832(1)
Exercises
832(1)
Day 8
833(2)
Quiz
833(1)
Exercises
834(1)
Day 9
835(2)
Quiz
835(1)
Exercises
835(2)
Day 10
837(5)
Quiz
837(1)
Exercises
838(4)
Day 11
842(4)
Quiz
842(1)
Exercises
842(4)
Day 12
846(1)
Quiz
846(1)
Exercises
846(1)
Day 13
847(1)
Quiz
847(1)
Exercises
847(1)
Day 14
848(2)
Quiz
848(1)
Exercises
849(1)
Day 15
850(6)
Quiz
850(1)
Exercises
850(6)
Day 16
856(3)
Quiz
856(1)
Exercises
856(3)
Day 17
859(3)
Quiz
859(1)
Exercises
860(2)
Day 18
862(1)
Quiz
862(1)
Exercises
863(1)
Day 19
863(4)
Quiz
863(1)
Exercises
864(3)
Day 20
867(6)
Quiz
867(1)
Exercises
868(5)
Day 21
873(2)
Quiz
873(1)
Exercises
874(1)
E A Look at Linked Lists
875(12)
The Component Parts of Your Linked List
876(11)
Index 887

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