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.

9780321246950

C++ Without Fear : A Beginner's Guide That Makes You Feel Smart

by
  • ISBN13:

    9780321246950

  • ISBN10:

    0321246950

  • Edition: CD
  • Format: Paperback w/CD
  • Copyright: 2005-01-01
  • Publisher: Prentice Hall
  • 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: $34.99

Summary

An experienced and highly regarded programming author makes C++ easy to learn - and fun - for complete novices.

Author Biography

Brian Overland has considerable experience programming with C++ and teaching basic techniques to others

Table of Contents

Preface xix
Why a New C++ Book? xix
What Else Is New about This Book? xx
Multiple Learning Paths: What Fits You Best xx
What If You Already Have a Programming Background? xxi
What Is Not Covered? xxi
Why Should Anyone Start with C++? xxii
To Get Started . . . xxiii
Tips and Tricks: What Do I Watch Out For? xxiii
Acknowledgments xxv
Your First C++ Programs
1(32)
Thinking like a Programmer
1(5)
Computers Do Only What You Tell Them
1(1)
Determine What the Program Will Do
2(1)
Write the Equivalent C++ Statements
2(2)
Some Nerdy Definitions---A Review
4(2)
What's Different about C++?
6(2)
Interlude What about Java and C#?
7(1)
Building a C++ Program
8(3)
Enter the Program Statements
8(1)
Build the Program (Compile and Link)
9(1)
Test the Program
10(1)
Revise As Needed
10(1)
Installing Your Own C++ Compiler
11(1)
Print a Message
12(5)
If You're Using the RHIDE Environment
12(1)
If You're Using Microsoft Visual Studio
13(1)
How It Works
14(2)
Exercises
16(1)
Interlude What about #include and ``using''?
16(1)
Advancing to the Next Print Line
17(1)
Print Multiple Lines
18(2)
How It Works
18(1)
Exercises
19(1)
Interlude What Is a String?
20(1)
Storing Data: C++ Variables
20(1)
Introduction to Data Types
21(2)
Interlude Why Double Precision, Not Single?
23(1)
Convert Temperatures
23(6)
How It Works
25(2)
Variations on the Example
27(2)
Exercises
29(1)
A Word about Variable Names and Keywords
29(1)
Exercise
30(1)
Chapter 1 Summary
30(3)
Decisions, Decisions
33(32)
But First, a Few Words about Data Types
33(4)
Interlude For C Programmers
36(1)
Decision Making in Programs
37(1)
If and if-else
37(4)
Interlude Why Two Operators (= and ==)?
40(1)
Odd or Even?
41(3)
How It Works
42(1)
Optimizing the Code
43(1)
Exercise
44(1)
Introducing Loops
44(4)
Interlude Infinite Loopiness
48(1)
Print 1 to N
48(2)
How It Works
49(1)
Exercises
50(1)
True and False in C++
50(1)
Interlude The bool Data Type
51(1)
The Increment Operator (++)
51(2)
Statements vs. Expressions
53(1)
Introducing Boolean (Short-Circuit) Logic
54(2)
Interlude What Is ``true''?
55(1)
Testing a Person's Age
56(1)
How It Works
57(1)
Exercise
57(1)
Introducing the Math Library
57(1)
Prime-Number Test
58(3)
How It Works
60(1)
Optimizing the Program
61(1)
Exercise
61(1)
Chapter 2 Summary
61(4)
The Handy, All-Purpose ``for'' Statement
65(16)
Loops Used for Counting
65(1)
Introducing the ``for'' Loop
66(2)
A Wealth of Examples
68(2)
Interlude Does ``for'' Always Behave like ``while''?
69(1)
Printing 1 to N with ``for''
70(1)
How It Works
70(1)
Exercises
71(1)
Statement Blocks with ``for''
71(1)
Declaring Loop Variables on the Fly
72(1)
Prime-Number Test with ``for''
73(4)
How It Works
74(2)
Exercise
76(1)
Comparative Languages 101: The Basic ``for'' Statement
77(1)
Chapter 3 Summary
78(3)
Functions: Many Are Called
81(30)
The Concept of Function
81(2)
Function Calls and the Flow of the Program
83(1)
The Basics of Using Functions
84(4)
Step One: Declare (Prototype) the Function
85(1)
Step Two: Define the Function
86(1)
Step Three: Call the Function
87(1)
Triangle-Number Function
88(4)
How It Works
89(1)
Optimizing the Program
90(2)
Exercises
92(1)
Prime-Number Function
92(3)
How It Works
93(2)
Exercises
95(1)
Local and Global Variables
95(2)
Recursive Functions
97(1)
Greatest Common Factor (GCF)
98(4)
How It Works
100(1)
Exercises
101(1)
Prime Factorization
102(4)
How It Works
103(2)
Interlude For Math Junkies
105(1)
Exercises
106(1)
Random-Number Generator
106(3)
How It Works
108(1)
Exercise
109(1)
Chapter 4 Summary
109(2)
Arrays: We've Got Their Number
111(28)
A First Look at C++ Arrays
111(2)
Initializing Arrays
113(1)
Zero-Based Indexing
114(1)
Interlude Why Use Zero-Based Indexes?
114(1)
Print Out Elements
115(2)
How It Works
116(1)
Exercises
117(1)
How Random Is Random?
117(5)
How It Works
120(2)
Exercises
122(1)
Strings and Arrays of Strings
122(1)
Card Dealer #1
123(3)
How It Works
125(1)
Exercise
126(1)
Card Dealer #2
126(4)
How It Works
128(2)
Exercise
130(1)
Card Dealer #3
130(5)
How It Works
132(2)
Optimizing the Program
134(1)
Exercise
135(1)
A Word to the Wise
135(1)
2-D Arrays: Into the Matrix
136(1)
Chapter 5 Summary
137(2)
Pointers: Getting a Handle on Data
139(24)
The Concept of Pointer
139(3)
Interlude What Do Addresses Really Look Like?
140(2)
Declaring and Using Pointers
142(3)
The Double-It Function
145(2)
How It Works
145(2)
Exercises
147(1)
Swap: Another Function Using Pointers
147(2)
Array Sorter
149(5)
How It Works
152(1)
Exercises
153(1)
Pointer Arithmetic
154(2)
Pointers and Array Processing
156(1)
Zero Out an Array
157(4)
How It Works
158(1)
Optimizing the Program
159(1)
Exercises
160(1)
Chapter 6 Summary
161(2)
Strings: Analyzing the Text
163(34)
Text Storage on the Computer
163(2)
Interlude How Does the Computer Translate Programs?
164(1)
It Don't Mean a Thing If It Ain't Got That String
165(1)
String-Manipulation Functions
166(2)
Building Strings
168(4)
How It Works
170(1)
Exercises
171(1)
Interlude What about Escape Sequences?
172(1)
Reading String Input
172(3)
Get a Number
175(2)
How It Works
176(1)
Exercise
177(1)
Convert to Uppercase
177(3)
How It Works
178(1)
Exercises
179(1)
Individual Characters vs. Strings
180(1)
Analyze Input
181(5)
How It Works
183(2)
Exercises
185(1)
The New C++ String Class
186(3)
Include String-Class Support
187(1)
Declare and Initialize Variables of Type String
187(1)
Working with Variables of Type String
188(1)
Input and Output
189(1)
Building Strings with the string Type
189(2)
How It Works
190(1)
Exercises
191(1)
Other Operations on the string Type
191(2)
Chapter 7 Summary
193(4)
Files: Electronic Storage
197(22)
Introducing File-Stream Objects
197(2)
How to Refer to Disk Files
199(1)
Write Text to a File
200(3)
How It Works
201(1)
Exercises
202(1)
Display a Text File
203(3)
How It Works
204(1)
Exercises
205(1)
Text Files vs. ``Binary'' Files
206(2)
Interlude Are ``Binary Files'' Really More Binary?
208(1)
Introducing Binary Operations
208(3)
Random-Access Write
211(3)
How It Works
213(1)
Exercises
214(1)
Random-Access Read
214(3)
How It Works
216(1)
Exercises
216(1)
Chapter 8 Summary
217(2)
Some Advanced Programming Techniques
219(26)
Command-Line Arguments
219(2)
Display File from Command Line
221(3)
How It Works
223(1)
Exercises
223(1)
Function Overloading
224(2)
Interlude Overloading and OOPS
225(1)
Printing Different Types of Arrays
226(2)
How It Works
227(1)
Exercise
228(1)
The do-while Loop
228(2)
The switch-case Statement
230(1)
Multiple Modules
231(3)
Exception Handling
234(5)
Say Hello to Exceptions
234(1)
Handling Exceptions: A First Attempt
235(1)
Introducing try-catch Exception Handling
236(3)
Exception Handling with GCF
239(3)
How It Works
240(1)
Exercise
241(1)
Interlude Can I Use Multiple try-catch Blocks?
241(1)
Chapter 9 Summary
242(3)
Getting Yourself Object Oriented
245(16)
Why Get Object Oriented?
245(2)
A String Parser
247(1)
Objects vs. Classes
248(1)
Another Example: The Fraction Class
249(1)
Object Creation and Destruction
250(1)
Inheritance, or Subclassing
251(1)
Creating Shared Interfaces
252(1)
Polymorphism: True Object Independence
253(2)
Polymorphism and Virtual Functions
255(2)
Interlude Polymorphism and Traditional Languages
256(1)
What about Reusability?
257(2)
Chapter 10 Summary
259(2)
The Fraction Class
261(30)
Point: A Simple Class
261(2)
Interlude For C Programmers: Structures and Classes
263(1)
Private: Members Only (Protecting the Data)
263(3)
Testing the Point Class
266(2)
How It Works
267(1)
Exercises
268(1)
Introducing the Fraction Class
268(3)
Inline Functions
271(2)
Find the Greatest Common Factor
273(2)
Find the Lowest Common Multiple
275(1)
Fraction Support Functions
276(4)
How It Works
278(1)
Exercises
279(1)
Testing the Fraction Class
280(3)
How It Works
282(1)
Exercise
283(1)
Interlude A New Kind of #include?
283(1)
Fraction Arithmetic: add and mult
283(5)
How It Works
287(1)
Exercises
288(1)
Chapter 11 Summary
288(3)
Constructors: If You Build It . . .
291(22)
Introducing Constructors
291(2)
Multiple Constructors (Overloading)
293(1)
The Default Constructor...and a Warning
294(2)
Interlude Is C++ Out to Trick You with the Default Constructor?
295(1)
Point Class Constructors
296(3)
How It Works
298(1)
Exercises
298(1)
Fraction Class Constructors
299(3)
How It Works
301(1)
Exercises
302(1)
Reference Variables and Arguments (&)
302(2)
The Copy Constructor
304(2)
Interlude The Copy Constructor and References
305(1)
Fraction Class Copy Constructor
306(4)
How It Works
309(1)
Exercises
310(1)
Chapter 12 Summary
310(3)
Operator Functions: Doing It with Class
313(30)
Introducing Class Operator Functions
313(3)
Operator Functions As Global Functions
316(2)
Improve Efficiency with References
318(2)
Point Class Operators
320(3)
How It Works
322(1)
Exercises
323(1)
Fraction Class Operators
323(5)
How It Works
326(2)
Exercises
328(1)
Working with Other Types
328(1)
The Class Assignment Function (=)
329(1)
The Test-for-Equality Function (==)
330(2)
Interlude What about the Boolean Type (bool)?
331(1)
A Class ``Print'' Function
332(1)
The Completed Fraction Class
333(6)
How It Works
337(1)
Exercises
338(1)
Chapter 13 Summary
339(4)
What's ``new'': The StringParser Class
343(20)
The ``new'' Operator
343(2)
Objects and ``new''
345(2)
Allocating Array Data
347(2)
Interlude Dealing with Problems in Memory Allocation
348(1)
Dynamic Memory in Action
349(1)
How It Works
350(1)
Exercise
350(1)
Design for a Parser (Lexical Analyzer)
350(5)
The StringParser Class
355(6)
How It Works
358(2)
Improving the Code
360(1)
Exercises
360(1)
Chapter 14 Summary
361(2)
What's ``this'': The String Class
363(22)
Introducing the String Class
363(1)
Introducing Class Destructors
364(2)
A Simple String Class
366(4)
How It Works
367(3)
Exercises
370(1)
``Deep'' Copying and the Copy Constructor
370(2)
The ``this'' Keyword
372(2)
Revisiting the Assignment Operator
374(1)
Writing a Concatenation Function
375(2)
The Complete String Class
377(5)
How It Works
380(1)
Exercises
381(1)
Chapter 15 Summary
382(3)
Inheritance: What a Legacy
385(28)
Subclassing for Fun and Profit
385(4)
Interlude Why ``public'' Base Classes?
388(1)
The FloatFraction Class
389(5)
How It Works
393(1)
Exercises
394(1)
Problems with the FloatFraction Class
394(4)
Default Constructors for Subclasses
396(1)
Copy Constructors for Subclasses
396(1)
Assignment Function for Subclasses
396(1)
Add the Missing Constructors
396(1)
Resolving Type Conflicts with the Base Class
397(1)
The Completed FloatFraction Class
398(1)
How It Works
399(1)
Exercises
399(1)
The ProperFraction Class
399(5)
How It Works
402(2)
Exercises
404(1)
Private and Protected Members
404(2)
Contained Members: FractionUnits
406(4)
How It Works
408(2)
Exercise
410(1)
Chapter 16 Summary
410(3)
Polymorphism: Object Independence
413(22)
A Different Approach to the FloatFraction Class
413(2)
Virtual Functions to the Rescue!
415(3)
Interlude What Is the Virtual Penalty?
416(2)
The Revised FloatFraction Class
418(5)
How It Works
420(1)
Improving the Code
421(2)
Exercise
423(1)
``Pure Virtual'' and Other Arcane Matters
423(1)
Abstract Classes and Interfaces
424(2)
Why cout Is Not Truly Polymorphic
426(1)
True Polymorphism: The Printable Class
427(4)
How It Works
429(2)
Exercise
431(1)
A Final Word (or Two)
431(1)
A Final Final Word
432(1)
Chapter 17 Summary
433(2)
Appendix A C++ Operators
435(4)
Appendix B Intrinsic Data Types
439(2)
Appendix C C++ Syntax Summary
441(10)
Literal Constants
441(1)
Basic Expression Syntax
441(1)
Basic Statement Syntax
442(1)
Control Structures
443(2)
Special Control Statements
445(1)
Data Declarations
446(1)
Function Declarations
447(1)
Class Declarations
448(3)
Appendix D ASCII Codes
451(2)
Appendix E Common Library Functions
453(6)
String Functions
453(1)
Data-Conversion Functions
454(1)
Single-Character Functions
455(1)
Math Functions
455(2)
Randomization
457(2)
Appendix F Glossary of Terms
459(10)
Index 469

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.

Excerpts

In my ten years at Microsoft, I found the top-level programmers ("software development engineers," we called them) to be an interesting breed. Once you got them to open up and talk about their projects, they could be an articulate and passionate group. The trick was to get beyond the initial barrier, to convince them that you spoke their language. Experienced programmers sometimes divide the world into two groups: those who are "technical" and those who are not. At times a yawning gap seems to exist between them, like that between people with perfect pitch and those without. For programmers, the dividing line these days is most often the ability to program in C++. This attitude stems from the perception of C++ as difficult to learn. This book is dedicated to the idea that C++ need not be difficult. It's often a more challenging language than Basic, to be sure, but with the right kind of help,you can master the tricks of C++. Why a New C++ Book? Introductory programming books for C++ exist aplenty. But many--probably the great majority--are "introductory" only in the sense that they don't assume knowledge of C++ specifically. They usually assume that you've programmed in another language before, preferably in several. This book does not make that assumption. All that's required is that you're comfortable with a computer and that you've run applications such as a word processor or e-mail reader. Once you narrow the available C++ texts down to those that require no programming experience at all, there's a much smaller group of books from which to choose. What Else Is New about This Book? The book you hold in your hand stresses the fundamentals of programming. Yet even if you have programmed before (maybe you've taken a basic course in high school or college), you may find this a useful review. This book delves into thetopic of how to think like a programmer . . . and why specific language features matter. The why is as important as the how. People learn best when they get the benefit of several learning methods reinforcing one another. Therefore, every topic in this book is introduced by a general discussion with short program-code examples, accompanied by the following: A complete program example. Usually I provide a complete example that can be run and tested. The emphasis in this book is on short examples that do something interesting and useful and, when possible, something fun. Programming exercises. Each example has a series of accompanying exercises, in which I encourage you to modify the example or write similar programs, so that from the beginning you're writing C++ code. Answers to these exercises provided on the accompanying CD in the folder "Example Code and Answers to Exercises." Generous use of illustrations. Many so-called beginning texts don't use this approach at all. But I often find that the right figures can clarify an abstract concept. One picture is worth a thousand lectures, sometimes. A special "How It Works" section for every major example in the book. How-to program texts are notorious for giving you a long example followed by a couple of paragraphs of text. That's not the approach of this book. Complete examples are listed so that you can see everything in context. But after each example, I go back and dissect the program a couple of lines at a time, explaining how and why each bit of the program does what it does. Multiple Learning Paths: What Fits You Best In addition to the multiple learning techniques just described, this book contains frequent Interludes, where the more curious reader will find additional background and explanations why C++ features work the way they do. If you're eager to just get C++ programs working, you may want to skip the Interludes and return to them later. On

Rewards Program