SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION

Book description

C++ remains a popular object-oriented language and Sams Teach Yourself C++ in 10 Minutes provides a quick, focused way to learn the language. The author assumes no prior programming experience and begins by showing the reader the absolute fundamentals of what a program is and guides the readers to write their very first program. It covers all the important topics in C++ and provides a sold foundation on which to build programming knowledge. The material is reorganized to fit proven teaching techniques with about thirty percent of the text rewritten. All examples are new to comply with the current ANSI C++ standard and make them completely compatible with all popular compilers.

Table of contents

  1. Copyright
  2. About the Authors
  3. Acknowledgments
  4. We Want to Hear from You!
  5. Introduction
  6. Getting Started
    1. The Mission
    2. The C++ Language
    3. Preparing to Program
    4. C++, ANSI C++, Windows, and Other Areas of Confusion
    5. Your Compiler and Editor
    6. The Development Cycle
    7. Evolving the Program
    8. A Simple Program
    9. Parts of the Program
    10. Compile-Time Errors
    11. Summing Up
  7. Output to the Console—Standard Output
    1. Enhancing the Empty Program
    2. The #include, Character by Character
    3. Namespaces
    4. Comments
    5. Whitespace
    6. Functions
    7. The cout Statement, Word by Word
    8. Summing Up
  8. Calculations
    1. Performing and Displaying a Calculation
    2. Nesting Parentheses
    3. Using an Input Stream
    4. Using int Variables and Constants
    5. Types of Variables and Valid Names
    6. Summing Up
  9. Numeric Input
    1. Numeric Input
    2. What Went Wrong?
    3. Summing Up
  10. if Statements and Program Decisions
    1. Dealing with a Failed Input Stream
    2. Summing Up
  11. Exception Handling
    1. Exception Handling—A Better Way
    2. Why Use Exceptions?
    3. Summing Up
  12. Functions
    1. What Is a Function?
    2. Defining Functions
    3. Breaking the Example into Functions
    4. Refactoring
    5. Where You Put Function Code
    6. Global Variables
    7. Testing
    8. Summing Up
  13. Separating Code into Modules
    1. What Is a Module?
    2. Why Use a Module?
    3. Making a Library Changes Your Names
    4. Calling the Functions
    5. Compiling Separately
    6. Testing
    7. Summing Up
  14. do/while Loops
    1. Where You Are
    2. Doing Things More Than Once
    3. Doing Things at Least Once
    4. Doing Things Zero or More Times
    5. Summing Up
  15. Nested Loops and Complex bool Expressions
    1. Nesting Loops
    2. Relational Operators
    3. Simplifying by Using a bool Variable
    4. Summing Up
  16. switch Statements, static Variables, and runtime_errors
    1. switch Statements
    2. Generalizing the Calculator
    3. Dealing with the New Exception
    4. Summing Up
  17. Arrays, Loops, and the Increment and Decrement Operators
    1. Using an Array to Create a Calculator Tape
    2. The Tape
    3. The for Loop
    4. Writing Past the End of an Array
    5. Incrementing and Decrementing
    6. The Calculator Tape in the Accumulator
    7. Summing Up
  18. Storage: Heaps, Stacks, and Pointing
    1. Heaps Versus Stacks
    2. Pointers, References, and Arrays
    3. Pointers Are Dangerous
    4. Deleting from the Heap
    5. Deleting Arrays
    6. Summing Up
  19. Testing
    1. Why Storage from the Heap Makes Testing Critical
    2. Making the Calculator More General with a “Little Language”
    3. Debugging Without a Debugger
    4. Summing Up
  20. Structures and Types
    1. Getting Organized
    2. Declaring Enumerated Types
    3. Declaring Structure Types
    4. Structures on the Stack
    5. Structures from the Heap
    6. A Unidirectional Linked List with Structures for the Tape
    7. Function Pointers and Callbacks
    8. Summing Up
  21. File I/O
    1. Saving the Tape Between Sessions
    2. Recalling the Tape
    3. Replaying the Tape to Restore State
    4. Summing Up
  22. Classes: Structures with Functions
    1. The Class as a Mini-Program
    2. Classes Versus Instances
    3. Constructors and Destructors
    4. The Copy Constructor and When You Need It
    5. Relaxing “Declare Before Use” Within Classes
    6. Summing Up
  23. Refactoring the Calculator with Classes
    1. Moving Functions into Classes
    2. Summing Up
  24. Implementing the Calculator as Classes
    1. Class Notation
    2. The Private and Public Members of aRequest
    3. Initialization
    4. Internal State
    5. Naming
    6. Moving Function Content into Member Functions
    7. The Object as Callback Structure
    8. Who Allocates, Who Deletes, Who Uses, What's Shared
    9. Summing Up
  25. The Rest of the Calculator as Classes
    1. Using a Standard C++ Library Class
    2. The User Interface in an Object
    3. The main.cpp
    4. Summing Up
  26. Function and Operator Overloading
    1. Declaring Overloaded Member Functions in a Class
    2. Overloaded Constructors
    3. What Does It Mean to Overload an Operator?
    4. Operator Overloading Can Be Dangerous
    5. Overloading Assignment and the Copy Constructor
    6. Summing Up
  27. Inheritance
    1. Declaring Inheritance
    2. Referring to an Object as Its Class or Its Superclass
    3. Overriding Functions
    4. Protected Access
    5. What Is virtual?
    6. Virtual Constructors and Destructors
    7. Virtual Member Functions
    8. Calling the Superclass
    9. Summing Up
  28. Object Testing Using Inheritance
    1. Writing Test Harnesses
    2. Testing the Classes with Known Cases
    3. Regression Testing
    4. Summing Up
  29. Abstract Classes, Multiple Inheritance, and Static Members
    1. Creating Interfaces
    2. Multiple Inheritance
    3. Static Member Variables and Functions in Classes
    4. Summing Up
  30. Templates
    1. Strengths and Weaknesses of Templates
    2. Declaring and Using Templates
    3. Summing Up
  31. Performance: C++ Optimizations
    1. Running Faster, Getting Smaller
    2. Inlining
    3. Incrementing and Decrementing
    4. Templates Versus Generic Classes
    5. Timing Your Code
    6. Program/Data Structure Size
    7. Summing Up
  32. Wrapping Up
    1. Things You Can Do to Enhance the Calculator
    2. Lessons Learned
  33. Operators
  34. Operator Precedence
  35. Index

Product information

  • Title: SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION
  • Author(s): Jesse Liberty
  • Release date: May 2002
  • Publisher(s): Sams
  • ISBN: 0672324253