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

  • ISBN13:


  • ISBN10:


  • Edition: 2nd
  • Format: Paperback
  • Copyright: 2011-04-21
  • Publisher: Prentice Hall
  • View Upgraded Edition

Note: Supplemental materials are not guaranteed with Rental or Used book purchases.

Purchase Benefits

  • 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.
  • Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $40.00 Save up to $21.33
  • Buy Used


Supplemental Materials

What is included with this book?

  • The Used 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.


If you've always wanted to learn how to program a computer, or to learn the popular C++ programming language in particular, this book offers an ideal way to get you started. You'll find here everything you need, patiently explained and clearly illustrated, from general programming concepts and techniques to the particulars of the C++ language. In no time, you'll be writing and showing off your own programs! #xA0; Yes, programming can be a complex task, and C++ is a language often used by professionals. In fact, many of the coolest games, graphics, and Internet applications are created with C++, and it's even been used on the Mars rovers. But the language, like the monster pictured on the cover, need not be all that fearsome. Broken down to its essentials, and enhanced by simple examples and practical exercises, you'll be amazed at the quick progress you can make. #xA0; With C++ Without Fear, Second Edition,you will Learn the basics of C++ programming Get started writing your own programs See how and why each piece of a program does what it does Create useful and reusable program code Understand object-oriented programming#xD1;for once explained in simple, down-to-earth terms New and Improved While compatible with nearly every version of the C++ language, this second edition has been updated to cover important features of the newest and greatest C++ standard. In addition, it now includes Even more figures, examples, and exercises Even more puzzles and games An expanded 70-page language reference Instructions for downloading free C++ software Whether you wish to learn C++ programming for pleasure--and you'll discover here how much fun it can be--or you're considering a career in programming, this book is an intelligent first step.

Author Biography

Brian Overland has professional experience as a programmer on large commercial projects, as an author of six books, and as a teacher of programming. At Microsoft, he was a programmer, writer, and manager, winning several awards for writing. He’s been involved with several hi-tech start-ups since then. When not programming or writing programming books, Brian is an actor and novelist.

Table of Contents

Preface xxiii

Acknowledgments xxix

About the Author xxxi


Chapter 1: Your First C++ Programs 1

Thinking Like a Programmer 1

What’s Different About C++? 7

Building a C++ Program 8

Installing Your Own C++ Compiler 10

Advancing to the Next Print Line 16

Storing Data: C++ Variables 19

Introduction to Data Types 20

A Word about Variable Names and Keywords 28

Chapter 1 Summary 30


Chapter 2: Decisions, Decisions 33

But First, a Few Words about Data Types 33

Decision Making in Programs 34

Introducing Loops 43

True and False in C++ 50

The Increment Operator (++) 51

Statements vs. Expressions 52

Introducing Boolean (Short-Circuit) Logic 53

Introducing the Math Library 57

Chapter 2 Summary 64


Chapter 3: The Handy, All-Purpose “for” Statement 67

Loops Used for Counting 67

Introducing the “for” Loop 68

A Wealth of Examples 70

Compound Statements (Blocks) with “for” 74

Declaring Loop Variables on the Fly 74

Comparative Languages 101: The Basic “For” Statement 79

Chapter 3 Summary 80


Chapter 4: Functions: Many Are Called 83

The Concept of Function 83

The Basics of Using Functions 85

Local and Global Variables 93

Recursive Functions 95

Games and More Games 113

Chapter 4 Summary 115


Chapter 5: Arrays: All in a Row... 117

A First Look at C++ Arrays 117

Initializing Arrays 119

Zero-Based Indexing 119

Strings and Arrays of Strings 128

A Word to the Wise 141

2-D Arrays: Into the Matrix 142

Chapter 5 Summary 143


Chapter 6: Pointers: Getting a Handle on Data 145

What the Heck Is a Pointer, Anyway? 145

The Concept of Pointer 146

Declaring and Using Pointers 148

Swap: Another Function Using Pointers 155

Pointer Arithmetic 161

Pointers and Array Processing 163

Chapter 6 Summary 168


Chapter 7: Strings: Analyzing the Text 169

Text Storage on the Computer 169

It Don’t Mean a Thing If It Ain’t Got That String 171

String-Manipulation Functions 172

Reading String Input 178

Individual Characters vs. Strings 185

The New C++ String Type 189

Other Operations on the string Type 193

Chapter 7 Summary 194


Chapter 8: Files: Electronic Storage 197

Introducing File-Stream Objects 197

How to Refer to Disk Files 199

Text Files vs. “Binary” Files 206

Introducing Binary Operations 208

Chapter 8 Summary 217


Chapter 9: Some Advanced Programming Techniques 221

Command-Line Arguments 221

Function Overloading 227

The do-while Loop 230

The switch-case Statement 232

Multiple Modules 234

Exception Handling: I Take Exception to That! 237

Chapter 9 Summary 240


Chapter 10: New Features of C++0x 243

Overview of C++0x Features 243

The long long Type (not long long long) 244

Range-Based “for” (For Each) 256

The auto and decltype Keywords 261

The nullptr Keyword 262

Strongly Typed Enumerations 263

Raw String Literals 273

Chapter 10 Summary 273


Chapter 11: Introducing Classes: The Fraction Class 277

Object Orientation: Quasi-Intelligent Data Types 277

Point: A Simple Class 279

Private: Members Only (Protecting the Data) 281

Introducing the Fraction Class 286

Inline Functions 289

Find the Greatest Common Factor 291

Find the Lowest Common Denominator 292

Chapter 11 Summary 305


Chapter 12: Constructors: If You Build It… 307

Introducing Constructors 307

Multiple Constructors (Overloading) 309

C++0x Only: Initializing Members within a Class 309

The Default Constructor–and a Warning 310

C++0x Only: Delegating Constructors 313

C++0x Only: Consistent Initialization 314

Reference Variables and Arguments (&) 321

The Copy Constructor 323

A Constructor from String to Fract 329

Chapter 12 Summary 331


Chapter 13: Operator Functions: Doing It with Class 333

Introducing Class Operator Functions 333

Operator Functions as Global Functions 336

Improve Efficiency with References 338

Working with Other Types 348

The Class Assignment Function (=) 349

The Test-for-Equality Function (==) 350

A Class “Print” Function 351

C++0x Only: User-Defined Literals 357

Chapter 13 Summary 360


Chapter 14: Dynamic Memory and the String Class 363

Dynamic Memory: The “new” Keyword 363

Objects and “new” 365

Allocating Multiple Data 366

Introducing Class Destructors 370

 “Deep” Copying and the Copy Constructor 376

The “this” Keyword 378

Revisiting the Assignment Operator 379

Writing a Concatenation Function 380

Chapter 14 Summary 387


Chapter 15: Two Complete OOP Examples 389

Introducing Linked Lists 389

Tower of Hanoi, Animated 402

Chapter 15 Summary 411


Chapter 16: Easy Programming with STL 413

Introducing the List Template 413

Designing an RPN Calculator 422

Correct Interpretation of Angle Brackets 432

Chapter 16 Summary 432


Chapter 17: Inheritance: What a Legacy 435

How to Subclass 435

Problems with the FloatFraction Class 440

C++ Only: Inheriting Base-Class Constructors 441

Protected Members 445

Object Containment 447

Safe Inheritance Through Class Hierarchies 448

Chapter 17 Summary 451


Chapter 18: Polymorphism: Object Independence 453

A Different Approach to the FloatFraction Class 453

Virtual Functions to the Rescue! 454

C++ Only: Requiring Explicit Overrides 460

“Pure Virtual” and Other Abstract Matters 461

Abstract Classes and Interfaces 462

Object Orientation and I/O 464

A Final Word (or Two) 470

A Final, Final Word 472

Chapter 18 Summary 472


Appendix A: Operators 475

The Scope (::) Operator 478

The sizeof Operator 478

Old and New Style Type Casts 479

Integer vs. Floating-Point Division 480

Bitwise Operators (&, , ^, ~, <<, and >>) 480

Conditional Operator 481

Assignment Operators 482

Join (,) Operator 482


Appendix B: Data Types 483

Precision of Data Types 484

Data Types of Numeric Literals 485

String Literals and Escape Sequences 486

Two’s Complement Format for Signed Integers 487


Appendix C: Syntax Summary 491

Basic Expression Syntax 491

Basic Statement Syntax 492

Control Structures and Branch Statements 493

Variable Declarations 498

Function Declarations 500

Class Declarations 502

Enum Declarations 503


Appendix D: Preprocessor Directives 505

The #define Directive 505

The ## Operator (Concatenation) 507

The defined Function 507

The #elif Directive 507

The #endif Directive 508

The #error Directive 508

The #if Directive 508

The #ifdef Directive 509

The #ifndef Directive 510

The #include Directive 510

The #line Directive 511

The #undef Directive 511

Predefined Constants 511


Appendix E: ASCII Codes 513


Appendix F: Standard Library Functions 517

String (C-String) Functions 517

Data-Conversion Functions 517

Single-Character Functions 517

Math Functions 520

Randomization Functions 521

Time Functions 521

Formats for the strftime Function 523


Appendix G: I/O Stream Objects and Classes 525

Console Stream Objects 525

I/O Stream Manipulators 526

Input Stream Functions 528

Output Stream Functions 528

File I/O Functions 529


Appendix H: STL Classes and Objects 531

The STL String Class 531

The <list> Template 533

The <stack> Template 535


Appendix I: Glossary of Terms 537


Index 553

Rewards Program

Write a Review