Home > Store

Learning to Program in C++

Register your product to gain access to bonus material or receive a coupon.

Learning to Program in C++

ValuePack

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

  • Features excerpts of actual e-mail between the author and the novice reviewer, so that readers will have the same insight (and access to the author) the review had.
    • Students get a unique two pronged approach to the material and can review both questions the novice asked along with the answers. This is a critical difference from the competition (see quotes).

  • This book covers key parts of the language and focuses on learning how to write actual programs that do something useful.
    • Students study examples that are valid ways to develop a system. Competitive books focus on language features rather than proper design principles and examples.

  • Tips throughout the book from the novice user.
    • The student has the opportunity to benefit from the novice's second and third read through of the book and get a real understanding of programming in C++.

Description

  • Copyright 2001
  • Edition: 1st
  • ValuePack
  • ISBN-10: 0-13-032410-8
  • ISBN-13: 978-0-13-032410-8

Start here if you want to master C++. No experience necessary. Honestly.

  • Learn C++ from a master: how to think like a programmer!
  • A remarkable personal dialogue between a C++ expert and a novice
  • From the absolute basics to advanced topics: inheritance, polymorphism, pointers, and more.

Even if you have absolutely no programming experience, this book will help you truly master C++.

You won't merely learn the basics. You'll master sophisticated, professional techniques—up to and including the effective use of encapsulation, inheritance, polymorphism, and pointers.

You'll never find yourself copying syntax without understanding it. You'll learn to think like a programmer, engineer code that delivers great reliability and performance, and avoid the pitfalls that await every new C++ developer.

These are powerful promises. But Learning to Program in C++ is a remarkable book.

It's a book-length dialogue between renowned C++ developer Steve Heller and a real-life programming novice-a novice with an uncanny ability to ask the questions you'd ask-and get crystal-clear, on-target answers.

It starts from absolute scratch, making only one assumption: you're ready to learn. And it's more like reading a novel—or participating in an intelligent discussion—than any computer book you've ever seen.

Steve Heller's Learning to Program in C++. It's a pleasure to read. And if you pay attention, you'll walk away with a superb understanding of C++: what to do, how to do it, and above all, why.

Previously published as Who's Afraid of C++? and Who's Afraid of More C++?: Both classic books, integrated and updated, together for the first time, at a great price!

Sample Content

Downloadable Sample Chapter

Click here for a sample chapter for this book: 0130324108.pdf

Table of Contents



Foreword.


Preface.


Acknowledgements.


Letter from a Novice.


1. Introduction to Programming.

Definitions. How to Write a Program. Baby Steps. On with the Show.



2. Hardware Fundamentals.

Definitions. Objectives of This Chapter. Behind the Curtain. Disk. 1985: A Space Odyssey. RAM. Return to Sender, Address Unknown. The CPU. RAM vs CPU Speeds. A Memory Hierarchy. Caching In. Please Register Here. Odometer Trouble. The First Few Numbers. The Next Few Numbers. How Many Combinations? Back to the Future. Over-Hexed. Binary to Hex Conversion Table. Different Representations of the Same Numbers. Exercises. Registering Relief. 32 and 16 Bit Registers, before Add Ax,1. 32 and 16 Bit Registers, after Add Ax,1. 32 and 16 Bit Registers, after Add Eax,1. On a RAMpage. Registering Bewilderment. 32- and 16-Bit Register Codes. Slimming the Program. A Fetching Tale. Instruction Execution Time, Using Registers and Prefetching. Review. Conclusion. Answers to Exercises.



3. Basics of Programming.

Definitions. Objectives of This Chapter. Speed Demon. Blaming It on the Computer. That Does Not Compute. Lost in Translation. A Little Numeric Calculation. What's Going on Underneath? A Small Section of RAM. Who's on First? One Little Endian. A Big Endian Example. Exercises, First Set. Exercise 1. Underware? A Really Little Numeric Calculation. Compiling, Part 3. Execution Is Everything. A Cast of Characters. Some Real Characters and Strings (Code\Basic00.Cc). Yet Another Small Section of RAM. A Byte by Any Other Name. Some Strings Attached. Special Characters for Program Text. Exercises, Second Set. A Small Section of RAM. In and Out. Some Simple Output (Code\Basic01.Cc). Some Simple Input and Output (Code\Basic02.Cc). If Only You Knew. Using an If Statement (Code\Basic03.Cc). While We're on the Subject. Using a While Statement (Code\Basic04.Cc). Exercises, Third Set. Just Up the Block. At the Fair. A C++ Program (Code\Pump1.Cc). Novice Alert. Take It for a Spin. Exercises, Fourth Set. Review. Conclusion. Answers to Exercises. First Dinner Party Program (Code\Basic05.Cc). Second Dinner Party Program (Code\Basic06.Cc). Else If Example. Name and Age Program (Code\Basic07.Cc). Novice Program (Code\Basic08.Cc). Allowance Program (Code\Basic09.Cc).



4. More Basics.

Objectives of This Chapter. Algorithmic Thinking. Finding the Top Two Weights, First Try (Code\Pump1a.Cc). A Prize Catch. Susan's Solution to the Bug in the First Attempt. Using an If Statement with an Else Clause. Finding the Top Two Weights (Code\Pump2.Cc). What A Tangled Web We Weave. You May Already Have Won. Variables, By The Numbers. Using A Vector (Code\Vect1.Cc). Zero Isn't Nothing. Index Variables. Using A For Statement (From Code\Vect1.Cc). Sorting The Weights (From Code\Vect1.Cc). Elements Vs Values. Details, Details. Initial Situation. After The First Pass. After The Second Pass. Final Situation. To Err Is Human. A Possible Error Message. Sorting The Weights, Again (From Code\Vect1.Cc). Sorting The Weights, With Correct Initialization (From Code\Vect2.Cc). To Really Foul Things Up Requires A Computer. What, Me Worry? Garbage In, Garbage Out. Garbage Prevention, First Attempt (From Code\Vect2a.Cc). Finding The Top Three Weights Using Vectors (Code\Vect3.Cc). Review. Exercises. Exercise 1 (Code\Morbas00.Cc). Exercise 2 (Code\Morbas01.Cc). Conclusion. Answers To Exercises. Weight Requesting Program, First Try (Code\Morbas02.Cc). Error Messages From The Erroneous Weight Program (Code\Morbas02.Cc). The Corrected Weight Program (Code\Morbas03.Cc). The Weight Totaling Program (Code\Morbas04.Cc).



5. Functional Literacy.

Definitions. Objectives of This Chapter. Functioning Normally. A Sample Program with Duplicated Code (Code\Nofunc.Cc). A Function Call. Above Average. A Function to Average Two Values. Return to Sender. For the Sake of Argument. Argument Passing with One Argument (Code\Birthday.Cc). General Delivery. Using a Function. Using the Average Function (Code\Func1.Cc). A Convincing Argument. The Man Behind the Curtain. The Object of My Affections. Making an Executable. Operating Systematically. Using Your Library Card. Automatic Pilot. Stacking the Deck. A Stack with One Entry. A Stack with Two Entries. A Stack with Three Entries. Don't Call Me, I'll Call You. How It All Stacks Up. An Empty Stack. The Stack Immediately after the Call to Average. The Stack after Auto Variable Allocation. Scoped Out. Scope Vs Storage Class. Static Cling. Using an Auto Variable and Initializing It (Code\Count1.Cc). Using an Auto Variable and Not Initializing It (Code\Count2.Cc). Using a Local Static Variable and Initializing It (Code\Count3.Cc). Using a Local Static Variable and Not Initializing It (Code\Count4.Cc). Using a Global Variable and Not Initializing It (Code\Count6.Cc). Using a Global Variable and Initializing It (Code\Count5.Cc). Using Variables of Different Scopes and Storage Classes (Code\Scopclas.Cc). The Results of Using Variables of Different Scopes and Storage Classes (Code\Scopclas.Out). Exercises, First Set. Exercise 1a (Code\Inita.Cc). Exercise 1b (Code\Initb.Cc). Exercise 1c (Code\Initc.Cc). Exercise 1d (Code\Initd.Cc). Exercise 1e (Code\Inite.Cc). Exercise 1f (Code\Initf.Cc). Think Globally? A BASIC Difficulty. I Say "Live It, Or Live with It". Nesting Instinct. The Stack after the Initialization of Result. The Stack after Exiting from Average. Review. Exercises, Second Set. Exercise 2 (Code\Calc1.Cc). Conclusion. Answers to Exercises. The Stack Immediately before the Call to Mess. Immediately before Executing the First Instruction in Mess. The Stack after Mess Has Declared the Auto Variable Xyz. The Stack after Xyz Has Been Initialized. The Stack before Counter Is Called. Immediately Upon Entry to Counter. Before Execution of the First Instruction in Counter.



6. Taking Inventory.

Definitions. Objectives Of This Chapter. Pay Some Attention To The Man Behind The Curtain. Taking Stock. The Initial Sample Program For The Stockitem Class (Code\Itemtst1.Cc). More Definitions. Common Behavior. Comparison Between Native And User-Defined Types. The Initial Interface Of The Stockitem Class (Code\Item1.H). The Default Constructor For The Stockitem Class (From Code\Item1.Cc). Another Way To Write The Default Stockitem Constructor. Go To The Head Of The Class. Shop Till You Drop. Another Constructor For The Stockitem Class (From Code\Item1.Cc). Display Member Function For The Stockitem Class (From Code\Item1.Cc). The Initial Interface Of The Stockitem Class (Code\Item1.H). The Initial Implementation Of The Stockitem Class (Code\Item1.Cc). Vectoring In. Reading And Displaying A Vector Of Stockitems (Code\Itemtst2.Cc). The Read Function For The Stockitem Class (From Code\Item2.Cc). The Second Version Of The Interface For The Stockitem Class (Code\Item2.H). References Required. Don't Fence Me In. Can I Help You? First Attempt To Update Inventory Of Stockitems (Code\Itemtst3.Cc). Access Denied. An Enhanced Interface For The Stockitem Class (Code\Item4.H). The Customer Is Always Right. Some New Functions For The Stockitem Class (From Code\Item4.Cc). Updating Stockitem Inventory (Code\Itemtst4.Cc). Next Customer, Please? Interface Of Inventory Class (Code\Invent1.H). Default Constructor For Inventory Class (From Code\Invent1.Cc). Loadinventory Function For Inventory Class (From Code\Invent1.Cc). Nothing Ventured, Nothing Gained. The Implementation Of Isnull (From Code\Item5.Cc). Finditem Function For Inventory Class (From Code\Invent1.Cc). Updateitem Function For Inventory Class (From Code\Invent1.Cc). The Implementation Of Getupc (From Code\Item5.Cc). The Implementation Of Getprice (From Code\Item5.Cc). Current Interface For Inventory Class (Code\Invent1.H). Current Implementation For Inventory Class (Code\Invent1.Cc). Current Interface For Stockitem Class (Code\Item5.H). Current Implementation For Stockitem Class (Code\Item5.Cc). Updated Inventory Application (Code\Itemtst5.Cc). Paging Rosie Scenario. Review. Exercises. Conclusion. Answers To Exercises. The Write Member Function For The Stockitem Class (From Code\Item6.Cc). The Storeinventory Member Function For The Inventory Class (From Code\Invent2.Cc). The Changes To The Application Program (From Code\Itemtst6.Cc).



7. Stringing Along.

Objectives of This Chapter. Playing out the String. The String Class Interface, Initial Version (Code\String1.H). The Initial Implementation for the String Class (Code\String1.Cc). The Default Constructor for the String Class (From Code\String1.Cc). Passing Along a Few Pointers. The Dynamic Duo, New and Delete. An Empty String in Memory. Our First Test Program for The String Class (Code\Strtst1.Cc). Caution: Construction Area. The Char* Constructor for the String Class (From Code\String1.Cc). String N During Construction. A Simple Test Program for the String Class (Code\Strtst1.Cc). Constructive Criticism? The Char* Constructor for the String Class, Again (From Code\String1.Cc). Tricky Assignment. String N in Memory. Strings N and S in Memory after Compiler-Generated =. Assignment Of Responsibility. Strings N and S in Memory after Custom =. References Required. The Declaration of Operator = For the String Class. Hello, Operator? Calling the Operator = Implementation. What Is the Meaning of This? The Assignment Operator (Operator =) For the String Class (from Code\String1.Cc). Equality Now! Please Delete Me, Let Me Go. Running on Empty. the Next Assignment. A Hypothetical Assignment Operator (Operator =) for the String Class with Explicit This. The Terminator. The Destructor for the String Class (from Code/String1.Cc). Review. Exercises. Exercise 1 (Code\Strex1.Cc). Exercise 2 (Code\Strex2.Cc). Exercise 3 (Code\Strex3.Cc). Conclusion. Answers to Exercises.



8. Down the Garden Path.

Objectives of This Chapter. For Reference Only. Call by Value ("Normal Argument") Using the Compiler-Generated Copy Constructor. Unfair Copy. Call by Reference. Our First Test Program for the String Class (Code\Strtst1.Cc). Temporary Help Wanted. Assigning a C String to a String Via String::String(Char*). Copy Cat. The String Class Interface (Code\String1.H). The Copy Constructor for the String Class. Screen Test. The String Class Interface, with Display Function (Code\String3.H). The String Class Test Program, Using the Display Function (Code\Strtst3.Cc). The String Class Implementation of the Display Function. A Character Study. Array of Hope? Dangerous Characters (Code\Dangchar.Cc). A Slippery Character. Overwrought. Reaping the Whirlwind. Private Property: Keep Out! Attempted Privacy Violation (Code\Strtst3a.Cc). Maintenance Required. Yet Another Version of the String Class Interface (Code\String4.H). The String Class Implementation of the Getlength Function (from Code\String4.Cc). Using the Getlength Function in the String Class (Code\Strtst4.Cc). First Review. a String of Wins. Sorting a Vector of Strings (Code\Strsort1.Cc). The Updated String Class Interface, Including Comparison and I/O Operators (Code\String5.H). Less Than Obvious. Down for the Count. Strings X and Y in Memory. Strings X and Y in Memory, with an Embedded Null Byte. Using Operator For Strings (Code\Strtst5x.Cc). The Implementation of Operator for Strings (from Code\String5a.Cc). For Better Or Worse? Is Our Character Less Than the Other One? (from Code\String5a.Cc). The Else Clause in the Comparison Loop (from Code\String5a.Cc). Handling the Return Value (from Code\String5a.Cc). A Greater Cause. Simple Pleasures. Implementing Operator for Strings (from Code\String5.Cc). Equalization of Opportunity. Implementing Operator == for Strings (From Code\String5.Cc). Displaying Expertise. Down by the Old Cout Stream. Chaining Several Operator << Expressions Together (Code\Cout1.Cc). Gently Down the Stream. Friends of Global Progress. An Operator << Function to Output a String (From Code\String5.Cc). Members and Friends Only. Why We Need a Global Function for Operator <<. Reader and Advisor. An Operator >> Function to Input a String (from Code\String 5.Cc). Initial Here. Error from an Uninitialized Const (Code\String5x.Out). Use of a Non-Const Array Size (Code\String5y.Cc). Trying to Compile a Program with a Non-Const Array Size (Code\String5y.Out). Pointers and Setters. Second Review. Exercises. Exercise 1 (Code\Strex5.Cc). Exercise 2 (Code\Strex6.Cc). Conclusion. Answers to Exercises. The String Class Interface File (From Code\String6.H). The String Class Implementation of Operator . The String Class Implementation of Operator =. The String Class Implementation of Operator != (from Code\String6.Cc). The String Class Implementation of Operator <W0=> (from Code\String6.Cc). The Test Program for the Comparison Operators of the String Class (Code\Strcmp.cc).



9. Stocking Up.

Definitions. Objectives of This Chapter. Under Control. The Next Stockitem Header File (Code\Item20.H). The Next Implementation of Stockitem (Code\Item20.Cc). Taking Inventory. The Next Header File for the Inventory Class (Code\Invent20.H). Claiming an Inheritance. The Stockitem Test Program for the Base Stockitem Class (Code\Itmtst20.Cc). The Implementation of the Inventory Class (Code\Invent20.Cc). The Reorder Function for the Stockitem Class (from Code\Item20.Cc). A Dated Approach. Ancestor Worship. Simplified Interface for Stockitem and Datedstockitem Classes (Code\Itema.H). A Simplified Stockitem Object. A Datedstockitem Object. More Definitions. Protection Racket. A Derived Class Object with Its Base Class Part. Stock Footage. The Next Version of the Inventory Control Test Program (Code\Itmtst21.Cc). Full Interface for Stockitem and Datedstockitem (Code\Item21.H). Latest Implementation of Stockitem Class and First Implementation of Datedstockitem Class (Code\Item21.H). Class Interests. Private Bequest. Getting Static. Datedstockitem::Today() (from Code\Item21.Cc). Stream of Consciousness. A Simple Stream Example (Code\Stream1.Cc). An Empty Ostream Object. An Ostream Object with Some Data. An Ostream Object with Some More Data. An Empty Ostream Object. We All Stream for Strstream. A Strstream Formatting Example (Code\Stream2.Cc). An Empty Strstream Object. A Strstream Object with Some Contents. A Strstream Object with Some More Contents. A Strstream Object with Even More Contents. A Strstream Object after Reading Its Contents. Use It or Lose It. Default Formatting Example (Code\Coutdef1.Cc). Output of Default Formatting Example (Code\Coutdef1.Out). Output of Controlled Formatting Example (Code\Coutdef2.Out). Manipulative Behavior. Controlled Formatting Example (Code\Coutdef2.Cc). Baseless Accusations? Default Constructor for Datedstockitem (from Code\Item21.Cc). Specifying the Base Class Constructor for a Derived Class Object. Constructing a Default Datedstockitem Object. Normal Constructor for Datedstockitem (from Code\Item21.Cc). Constructing a Datedstockitem Object. Reordering Priorities. Reorder Function for Datedstockitem (from Code\Item21.Cc). Calling Reorder through a Stockitem Pointer, Part 1. Calling Reorder through a Datedstockitem Pointer. Calling Reorder through a Stockitem Pointer, Part 2. Function Call Example (Code\Nvirtual.Cc). Function Call Example Output (Code\Nvirtual.Out). Simplified Implementation for Stockitem and Datedstockitem Classes (Code\Itema.Cc). Review. Exercises. Conclusion.



10. Pretty Poly.

Definitions. Objectives of This Chapter. Polymorphism. Virtual Certainty. Dangerous Polymorphism: Interfaces of Stockitem and Datedstockitem with Virtual Reorder Function (Code\Itemb.H). Virtual Function Call Example Output (Code\Virtual.Out). A Simplified Stockitem Object without Virtual Functions. Dangerous Polymorphism: A Simplified Stockitem Object with a Virtual Function. Dangerous Polymorphism: A Simplified Datedstockitem Object with a Virtual Function. Dangerous Polymorphism: Calling a Virtual Reorder Function Through a Stockitem Pointer to a Stockitem Object. Dangerous Polymorphism: Calling a Virtual Reorder Function Through a Datedstockitem Pointer to a Datedstockitem Object. Dangerous Polymorphism: Calling a Virtual Reorder Function through a Stockitem Pointer to a Datedstockitem Object. Dangerous Polymorphism: A Simplified Stockitem Object with Two Virtual Functions. Dangerous Polymorphism: A Simplified Datedstockitem with Two Virtual Functions. a Pointed Reminder. Dangerous Polymorphism: Using Operator << with a Stockitem* (Code\Polyioa.Cc). Result of Using Operator << With a Stockitem* (Code\Polyioa.Out). Dangerous Polymorphism: Stockitem Interface with Operator << and Operator >> (Code\Itemc.H). Dangerous Polymorphism: Stockitem Implementation with Operator << and Operator >> (Code\Itemc.Cc). Dangerous Polymorphism: The Implementation of Operator << with a Stockitem* (From Code\Itemc.Cc). The Old Switcheroo. Dangerous Polymorphism: Stockitem::Write (From Code\Itemc.Cc). Dangerous Polymorphism: Datedstockitem::Write (from Code\Itemc.Cc). It's Not Polite to Point. Dangerous Polymorphism: Using Operator >> and Operator << with a Stockitem* (Code\Polyiob.Cc). Dangerous Polymorphism: The Results of Using Operator >> and Operator << with a Stockitem* (Code\Polyiob.Out). Dangerous Polymorphism: The Implementation of Operator >> (From Code\Itemc.Cc). Exercises, First Set. Pretty Polly Morphic. More Definitions. Paging Miss Management. Dangerous Polymorphism: Using Operator >> and Operator << with a Stockitem* (Code\Polyiob.Cc). Safe Polymorphism: Using Operator >> and Operator << with a Polymorphic Stockitem (Code\Polyioc.Cc). Safe Polymorphism: The Polymorphic Object Version of the Stockitem Interface (Code\Itemp.H). We'll Manage Somehow. Safe Polymorphism: The Undatedstockitem and Datedstockitem Interfaces for the Polymorphic Version of Stockitem (Code\Itempi.H). Safe Polymorphism: The Implementation of the Undatedstockitem and Datedstockitem Classes (Code\Itemp.Cc). Safe Polymorphism: The Implementation of Operator << for a Polymorphic Stockitem (from Code\Itemp.Cc). Safe Polymorphism: A Polymorphic Stockitem Object with No Date. Safe Polymorphism: A Polymorphic Stockitem Object with a Date. A Simplified Version of the Structure of a Datedstockitem Object. Setting the Standard. Safe Polymorphism: The Default Constructor for the Polymorphic Stockitem Class (from Code\Itemp.Cc). Safe Polymorphism: A Default-Constructed Polymorphic Stockitem Object. Safe Polymorphism: The Default Constructor for the Undatedstockitem Class (From Code\Itemp.Cc). Base Instincts. Safe Polymorphism: Implementing a Special Protected Constructor for Stockitem (from Code\Itemp.Cc). References Count. Starring Sharon Sharalike. Safe Polymorphism: An Example Program for Reference-Counting with Stockitems (Code\Refcnt1.Cc). Safe Polymorphism: A Normal Constructor to Create a Stockitem without a Date (From Code\Itemp.Cc). Safe Polymorphism: A Polymorphic Stockitem Object with an Undatedstockitem Worker. Safe Polymorphism: A Normal Constructor That Constructs a Stockitem Having a Date (from Code\Itemp.Cc). Safe Polymorphism: A Polymorphic Stockitem Object with a Datedstockitem Worker. Safe Polymorphism: The Copy Constructor for Stockitem (from Code\Itemp.Cc). Safe Polymorphism: Two Polymorphic Stockitem Objects Sharing the Same Undatedstockitem Worker Object. Safe Polymorphism: The Assignment Operator (Operator =) for Stockitem (From Code\Itemp.Cc). Safe Polymorphism: Two Polymorphic Stockitem Objects Sharing the Same Datedstockitem Worker Object. Safe Polymorphism: A Polymorphic Stockitem Object. The Last Shall Be First. Safe Polymorphism: The Destructor for the Stockitem Class (from Code\Itemp.Cc). Going, Going, Gone. Safe Polymorphism: The Destructor for the Stockitem Class (from Code\Itemp.Cc). For the Benefit of Posterity. Review. Exercises, Second Set. Conclusion.



11. The Home Inventory Project.

Definitions. Objectives of This Chapter. Homing in. What It Is, Mama! Interface R Us. The Initial Interface for the Homeitem Manager Class (Code/Hmit1.H). Deja Vu All over Again. The Initial Interface for the Homeitembasic and Homeitemmusic Worker Classes (Code\Hmiti1.H). What They Don't Know Won't Hurt Them. The Initial Test Program for the Homeitem Classes (Code\Hmtst1.Cc). Results of Running the First Homeitem Test Program (Code\Hmit1.Out). Initial Implementation of Homeitem Manager and Worker Classes (Code\Hmit1.Cc). Homeitem::Write (from Code\Hmit1.Cc). The Homeitem Implementation of Operator >> (from Code\Hmit1.Cc). The (Incorrect) While Loop in the Original Implementation of Operator >>. Making All Local Stops. What Have I Started? A Legal Program (Code\Fortest.Cc). Stereo Typing. An Incorrect Default Constructor for the Homeitembasic Class. Homeitembasic::Gettype (from Code\Hmit1.Cc). Homeitemmusic::Gettype (from Code\Hmit1.Cc). Homeitembasic::Write (from Code\Hmit1.Cc). Virtual Reality. Homeitemmusic::Write (from Code\Hmit1.Cc). The Initial Homeinventory Class Interface (Code\Hmin2.H). The Initial Implementation of Homeinventory (Code\Hmin2.Cc). Waste Not, Want Not. You Can Get What You Need. Another Possible Implementation of Loadinventory (from Code\Hmin2a.Cc). A Smith and Wesson Beats Four Aces. Yet Another Implementation of Loadinventory (from Code\Hmin3.Cc). Everything Is More Complicated Than It Looks. Back to the Future. The Next Interface for the Homeinventory Class (Code\Hmin4.H). The Additem Member Function of Homeinventory (from Code\Hmin4.Cc). The New Interface for Homeitem (Code\Hmit4.H). The Implementation of Homeitem::Newitem() (From Code\Hmit4.Cc). The New Version Of Operator >> (from Code\Hmit4.Cc). Strong Like Bool. Homeitembasic::Formatteddisplay (from Code\Hmit4.Cc). Homeitemmusic::Formatteddisplay (from Code\Hmit4.Cc). Leaving Well Enough Alone. the Test Program for Adding a Homeitem Interactively (Hmtst4.Cc). The Next Version of the Interface for Homeinventory (Code\Hmin5.H). The Next Version of The Homeinventory Test Program (Code\Hmtst5.Cc). The Edititem Function of Homeinventory (From Code\Hmin5.Cc). 'Tis a Gift to Be Simple. The Latest Version of the Homeitem Class Interface (Code\Hmit5.H). Homeitem::Edit (from Code\Hmit5.Cc). Homeitembasic::Copydata(). Better Read Than Dead. The Latest Version of Operator >> (From Code\Hmit5.Cc). For Your Eyes Only. The Latest Version of the Interface for the Homeitem Worker Classes (Code\Hmiti5.H). U Pluribus Enum. Homeitembasic::Getfieldname (from Code\Hmit5.Cc). Taking a Shortcut. Homeitem::Read (from Code\Hmit5.Cc). Homeitembasic::Read (from Code\Hmit5.Cc). Homeitembasic::Readinteractive (from Code\Hmit5.Cc). This Must Be the Place. Homeitembasic::Readfromfile (From Code\Hmit5.Cc). Homeitembasic::Edit (From Code\Hmit5.Cc). Homeitembasic::Formatteddisplay (from Code\Hmit5.Cc). Homeitembasic::Editfield (from Code\Hmit5.Cc). Facing the Music. Homeitemmusic::Formatteddisplay (from Code\Hmit5.Cc). Maintaining Our Position. Homeitemmusic::Readinteractive (from Code\Hmit5.Cc). Homeitemmusic::Readfromfile (from Code\Hmit5.Cc). Homeitemmusic::Editfield (from Code\Hmit5.Cc). Review. Exercises. Conclusion.



12. Homeward Bound.

Definitions. Objectives of This Chapter. Super-String Theory. The New String Class Interface (Code\String7.H). Batteries Not #Included. Construction Ahead. Default Is Mine. A Simplified Interface File for w String Class (Code\String7x.H). An Alternate String(Short Length) Constructor (from Code\String7x.Cc). Warning: Explicit Material. An Explicit Constructor Call Vs an Implicit One (Code\Strtstx.Cc). The String(Short, Char) Constructor for the String Class (From Code\String7.Cc). Adding Insult to Injury. Using Operator + for String Concatenation (Code\Strtst7a.Cc). The Implementation of Operator + for the String Class (from Code\String7.Cc). Inner Peace. The New Implementation of Operator >> (from Code\String7.Cc). Location, Location, Location. Using String::Find_Nocase (Code\Strtst7b.Cc). The Implementation of String::Find_Nocase (from Code\String7.Cc). The Less_Nocase Function (from Code\String7.Cc). Home, Sweet Home. The Latest Home Inventory Application Program (Code\Hmtst6.Cc). The Latest Version of the Homeinventory Interface (Hmin6.H). Homeinventory::Finditembydescription (from Code\Hmin6.Cc). The New Version of the Homeitem Interface (Code\Hmit6.H). Homeitembasic::Isnull (from Code\Hmit6.Cc). Nothing Ventured, Nothing Gained. A Slightly Odd Default Constructor for Homeitem (From Code\Hmit2.Cc). Error Messages Triggered by Accidental Use of 0 to Initialize a String (Code\Hmit6a.Err). Putting It All Together. First Test Session: Change Requests and Problem Reports. Second Test Session: Change Requests and Problem Reports. Third Test Session: Change Requests and Problem Reports. Fourth Test Session: Change Requests and Problem Reports. Fifth Test Session: Change Requests and Problem Reports. Round and Round We Go. Review. Exercises. Conclusion.



13. Stealing Home.

Definitions. Objectives of This Chapter. The Final Voyage. The Main() Function of the Final Version of the Home Inventory Main Program (from Code\Hmtst8.Cc). The Menuitem Enum (from Code\Hmtst8.Cc). The Getmenuchoice Function (from Code\Hmtst8.Cc). Executemenuchoice (from Code\Hmtst8.Cc). Utility Room. The Homeutility Interface (Code\Hmutil1.H). Homeutility::Ignoretillcr (from Code\Hmutil1.Cc). Homeutility::Handleerror (from Code\Hmutil1.Cc). Homeutility::Checknumericinput (from Code\Hmutil1.Cc). Number, Please. Making a List, Checking It Twice. Homeutility::Checkdateinput (from Code\Hmutil1.Cc). Enter Here. Homeutility::Getnumberorenter (from Code\Hmutil1.Cc). Secret Decoder Ring Not Required. The Rest of the Story. I Can See Clearly Now. Homeutility::Clearrestofscreen (from Code\Hmutil1.Cc). The Final Frontier. The Homeutility::Selectitem Function (from Code\Hmutil1.Cc). Checking the Inventory. the Latest Header File for the Homeinventory Class (Code\Hmin8.H). The Latest Version of Additem (from Code\Hmin8.Cc). The New Version of the Edititem Function (from Code\Hmin8.Cc). The Latest Implementation of Locateitembydescription (from Code\Hmin8.Cc). Homeinventory::Locateitembycategory (from Code\Hmin8.Cc). The Printnames Function (from Code\Hmin8.Cc). The Printall Function (from Code\Hmin8.Cc). The Storeinventory Function (from Code\Hmin8.Cc). The Displayitem Function (from Code\Hmin8.Cc). A Better Sort of Function. The Sortinventorybyname Function (from Code\Hmin8.Cc). The Selectitembypartialname Function (from Code\Hmin8.Cc). The Selectitemfromnamelist Function (from Code\Hmin8.Cc). Categorical Imperative. The Selectitemfromcategorylist Function (from Code\Hmin8.Cc). The Deleteitem Function (from Code\Hmin8.Cc). Homing In. The New Operator >> Implementation (from Code\Hmit8.Cc). The Latest Version of the Homeitembasic::Edit Function (from Code\Hmit8.Cc). The Newest Version of Homeitembasic::Readinteractive (from Code\Hmit8.Cc). The New Version of the Homeitembasic::Edititem Function (from Code\Hmit8.Cc). The Latest Version of Homeitemmusic::Readinteractive (from Code\Hmit8.Cc). The Latest Version of Homeitemmusic::Editfield (from Code\Hmit8.Cc). Are We Having Fun Yet? Review. Exercises. Conclusion.



Appendix A: Tying Up Loose Ends.

Operator Precedence. Another Native Data Type. Wrapping Up.



Appendix B: Glossary.


About the Author.


Index.

Preface

Preface

Is this book for you? If you're a programmer in a language other than C++ and you want to upgrade your skills, then you shouldn't have much difficulty figuring that out for yourself by reading a few pages. But what if you have no previous programming experience? In that case, here's a little quiz that may help you decide:

  1. Do you want to know how the programs in your computer work inside and how to write some of your own?
  2. Are you willing to exert yourself mentally to learn a complex technical subject?
  3. Do you have a sense of humor?

If you've answered yes to these questions and follow through with the effort required, then you will get a lot out of this book.

The common wisdom states that programming is a difficult subject that should be reserved for a small number of specialists. One of the main reasons that I have written this book is that I believe this attitude is wrong; it is possible, and even desirable, for you to learn how programs work and how to write them. Those who don't understand how computers perform their seemingly magical feats are at an increasing disadvantage in a society ever more dependent on these extraordinary machines.

Regardless of the topic, I can see no valid reason for a book to be stuffy and dry, and I've done everything possible to make this one approachable. However, don't let the casual tone fool you into thinking that the subject is easy; there is no royal road to programming, any more than there is to geometry. Especially if you have no prior experience in programming, C++ will stretch your mind more than virtually any other area of study.

But why should you read this book rather than any of dozens of other introductory C++ books? The ingredient that makes this book unique is the participation of a real, live person who didn't already know the material before reading it: Susan Heller, my wife. Her main contribution has been to read every line of the first draft of the book and to ask questions via e-mail about anything she didn't understand. I answered her questions, also by e-mail, until both of us were satisfied that she understood the material in question and that the text was clear. After the text was otherwise complete, I extracted appropriate parts of the e-mail exchanges, edited them for spelling, punctuation, and so forth, and included them in the text where they will be most useful to the reader.

Of course, these exchanges do take up room in the book that might otherwise be filled with more information about C++ and programming. Therefore, if you want to get the absolute maximum of new information per page, you might want to select another book such as Bjarne Stroustrup's excellent book, The C++ Programming Language, 3rd Edition (ISBN 0-201-88954-4). However, the vast majority of messages I've received from readers of my other books for beginners have indicated that they found my approach very helpful, and I suspect that most readers of this book will feel the same.

Susan has written an account of her involvement in this project, which immediately follows this Preface. I recommend that you read that account before continuing with the technical material following it, as it explains how and why she contributed to making your task easier and more enjoyable.

Speaking of Susan, here is a bit of correspondence between us on the topic of how one should read this book, which occurred after her first reading of what is now Chapter 2, "Hardware Fundamentals," and Chapter 3, "Basics of Programming."

Susan: Let me say this: to feel like I would truly understand it, I would really need to study this about two more times. Now, I could do this, but I am not sure you would want me to do so. I think reading a chapter once is enough for most people.

Steve: As a matter of fact, I would expect the reader of my book to read and study this chapter several times if necessary; for someone completely new to programming, I imagine that it would be necessary. Programming is one of the most complex human disciplines, although it doesn't take the mathematical skills of a subject such as nuclear physics, for example. I've tried to make my explanations as simple as possible, but there's no way to learn programming (or any other complex subject) without investing a significant amount of work and thought.

After she had gone through the text a number of times and had learned a lot from the process, we continued this discussion as follows:

Susan: Well then, maybe this should be pointed out in a Preface or something. Of course, it would eventually be obvious to the reader as it was to me, but it took me a while to come to that conclusion. The advantage of knowing this in advance is that maybe I would not be so discouraged that I was not brilliant after one read of a chapter.

Steve: I will indeed mention in the preface that the reader shouldn't be fooled by the casual tone into thinking that this is going to be a walk in the park. In any event, please don't be discouraged. It seems to me that you have absorbed a fair amount of very technical material with no previous background; that's something to be proud of!

We'll be hearing from Susan many more times in the course of the book. She will be checking in frequently in the form of extracts from the e-mail discussion we engaged in during the testing and revising process. I hope you will find her comments and my replies add a personal touch to your study of this technical material.

While we're on the topic of your studying, this would be a good time to tell you how to get updates and help with any errors you might find in the book or with any other questions you might have. The best way is to visit my WWW site, http://www.steveheller.com. My email address is steve@steveheller.com.

In the event that you enjoy this book and would like to tell others about it, you might want to write an online review on Amazon.com, which you can do by visiting my home page and following the links to the "customer reviews" on Amazon.

I should also tell you how the various typefaces are used in the book. Helvetica is used for program listings, for terms used in programs, and for words defined by the C++ language. Italics are used primarily for technical terms that are found in the glossary, although they are also used for emphasis in some places. The first time that a particular technical term is used, it is in bold face; if it is a term defined in the C++ language, it will be in bold Helvetica.

Now that those preliminaries are out of the way, let's proceed. The next voice you will hear is that of Susan, my test reader. I hope you get as much out of her participation in this book as I have.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020