C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart, Third Edition

Book description

Learning C++ Doesn’t Have to Be Difficult!

Have you ever wanted to learn programming? Have you ever wanted to learn the C++ language behind many of today’s hottest games, business programs, and even advanced spacecraft? C++ Without Fear, Third Edition, is the ideal way to get started. Now updated for the newest C++14 standard and the free Microsoft Visual C++ Community Edition, it will quickly make you productive with C++ even if you’ve never written a line of code!

Brian Overland has earned rave reviews for this book’s approach to teaching C++. He starts with short, simple examples you can easily enter and run. Within a couple of chapters, you’ll be creating useful utilities, playing games, and solving puzzles. Everything’s simplified to its essentials, patiently explained, and clearly illustrated with practical examples and exercises that help you make progress quickly.

Overland reveals the “whys” and “tricks” behind each C++ language feature. And you’ll never get bogged down in complex or pointless examples: He keeps you 100% focused on learning what works and what matters—while having fun!

This new and improved edition

  • Covers installing and using the free Microsoft Visual C++ Community Edition—but you can use any version of C++

  • Explains valuable improvements in the new C++14 standard

  • Modularizes C++14 coverage so it’s easy to write code that works with older versions

  • Teaches with even more puzzles, games, and relevant exercises

  • Offers more “why” and “how-to” coverage of object orientation, today’s #1 approach to programming

  • Presents more ways to use Standard Template Library (STL) code to save time and get more done

  • Contains an expanded reference section for all your day-to-day programming

  • Whether you want to learn C++ programming for pleasure or you’re considering a career in programming, this book is an outstanding choice.

    Table of contents

    1. About This E-Book
    2. Title Page
    3. Copyright Page
    4. Praise for Previous Editions of C++ Without Fear
    5. Dedication Page
    6. Contents
    7. Preface
      1. We’ll Have Fun, Fun, Fun...
      2. Why C and C++?
      3. C++: How to “Think Objects”
      4. Purpose of the Third Edition
      5. Where Do I Begin?
      6. Icons and More Icons
      7. Anything Not Covered?
      8. A Final Note: Have Fun!
    8. Acknowledgments
    9. About the Author
    10. 1. Start Using C++
      1. Install Microsoft Visual Studio
      2. Create a Project with Microsoft
      3. Writing a Program in Microsoft Visual Studio
      4. Running a Program in Visual Studio
      5. Compatibility Issue #1: stdafx.h
      6. Compatibility Issue #2: Pausing the Screen
      7. If You’re Not Using Microsoft
        1. How It Works
        2. Exercises
      8. Advancing to the Next Print Line
        1. How It Works
        2. Exercises
      9. Storing Data: C++ Variables
      10. Introduction to Data Types
        1. How It Works
        2. Optimizing the Program
        3. Exercises
      11. A Word about Variable Names and Keywords
        1. Exercise
      12. Chapter 1 Summary
    11. 2. Decisions, Decisions
      1. But First, a Few Words about Data Types
      2. Decision Making in Programs
        1. if and if-else
        2. How It Works
        3. Optimizing the Code
        4. Exercise
      3. Introducing Loops
        1. How It Works
        2. Optimizing the Program
        3. Exercises
      4. True and False in C++
      5. The Increment Operator (++)
      6. Statements versus Expressions
      7. Introducing Boolean (Short-Circuit) Logic
        1. How It Works
        2. Exercise
      8. Introducing the Math Library
        1. How It Works
        2. Optimizing the Program
        3. Exercise
        4. How It Works
        5. Exercises
      9. Chapter 2 Summary
    12. 3. And Even More Decisions!
      1. The do-while Loop
        1. How It Works
        2. Exercises
      2. Introducing Random Numbers
        1. How It Works
        2. Optimizing the Code
        3. Exercises
      3. The switch-case Statement
        1. How It Works
        2. Exercises
      4. Chapter 3 Summary
    13. 4. The Handy, All-Purpose “for” Statement
      1. Loops Used for Counting
      2. Introducing the “for” Loop
      3. A Wealth of Examples
        1. How It Works
        2. Exercises
      4. Declaring Loop Variables “On the Fly”
        1. How It Works
        2. Exercise
      5. Comparative Languages 101: The Basic “For” Statement
      6. Chapter 4 Summary
    14. 5. Functions: Many Are Called
      1. The Concept of Function
      2. The Basics of Using Functions
        1. Step 1: Declare (Prototype) the Function
        2. Step 2: Define the Function
        3. Step 3: Call the Function
        4. How It Works
        5. Function, Call a Function!
        6. Exercises
        7. How It Works
        8. Exercises
      3. Local and Global Variables
      4. Recursive Functions
        1. How It Works
        2. Exercises
        3. How It Works
        4. Exercises
        5. How It Works
        6. Exercises
        7. How It Works
        8. Exercises
      5. Games and More Games
      6. Chapter 5 Summary
    15. 6. Arrays: All in a Row...
      1. A First Look at C++ Arrays
      2. Initializing Arrays
      3. Zero-Based Indexing
        1. How It Works
        2. Exercises
        3. How It Works
        4. Exercises
      4. Strings and Arrays of Strings
        1. How It Works
        2. Exercises
        3. How It Works
        4. Exercises
      5. 2-D Arrays: Into the Matrix
      6. Chapter 6 Summary
    16. 7. Pointers: Data by Location
      1. What the Heck Is a Pointer, Anyway?
      2. The Concept of Pointer
      3. Declaring and Using Pointers
        1. How It Works
        2. Exercises
      4. Data Flow in Functions
      5. Swap: Another Function Using Pointers
        1. How It Works
        2. Exercises
      6. Reference Arguments (&)
      7. Pointer Arithmetic
      8. Pointers and Array Processing
        1. How It Works
        2. Writing More Compact Code
        3. Exercises
      9. Chapter 7 Summary
    17. 8. Strings: Analyzing the Text
      1. Text Storage on the Computer
      2. It Don’t Mean a Thing if It Ain’t Got that String
      3. String-Manipulation Functions
        1. How It Works
        2. Exercises
      4. Reading String Input
        1. How It Works
        2. Exercise
        3. How It Works
        4. Exercises
      5. Individual Characters versus Strings
        1. How It Works
        2. Exercises
      6. The C++ String Class
        1. Include String-Class Support
        2. Declare and Initialize Variables of Class string
        3. Working with Variables of Class string
        4. Input and Output
        5. How It Works
        6. Exercises
        7. How It Works
        8. Exercises
      7. Other Operations on the string Type
      8. Chapter 8 Summary
    18. 9. Files: Electronic Storage
      1. Introducing File—Stream Objects
        1. How to Refer to Disk Files
        2. How It Works
        3. Exercises
        4. How It Works
        5. Exercises
      2. Text Files versus “Binary” Files
      3. Introducing Binary Operations
        1. How It Works
        2. Exercises
        3. How It Works
        4. Exercises
      4. Chapter 9 Summary
    19. 10. Classes and Objects
      1. OOP, My Code Is Showing
      2. What’s an Object, Anyway?
      3. Point: A Simple Class
      4. Private: Members Only (Protecting the Data)
        1. How It Works
        2. Exercises
      5. Introducing the Fraction Class
      6. Inline Functions
      7. Find the Greatest Common Factor
      8. Find the Lowest Common Denominator
        1. How It Works
        2. Exercises
        3. How It Works
        4. Exercises
        5. How It Works
        6. Exercises
      9. Chapter 10 Summary
    20. 11. Constructors: If You Build It...
      1. Introducing Constructors
      2. Multiple Constructors (Overloading)
      3. C++11/C++14 Only: Initializing Members
      4. The Default Constructor—and a Warning
      5. C++11/C++14 Only: Delegating Constructors
        1. How It Works
        2. Exercises
        3. How It Works
        4. Exercises
      6. Reference Variables and Arguments (&)
      7. The Copy Constructor
      8. A Constructor from String to Fract
      9. Chapter 11 Summary
    21. 12. Two Complete OOP Examples
      1. Dynamic Object Creation
      2. Other Uses of new and delete
      3. Blowin’ in the Wind: A Binary Tree App
      4. The Bnode Class
      5. The Btree Class
        1. How It Works
        2. Exercises
      6. Tower of Hanoi, Animated
        1. After Mystack Class Design
        2. Using the Cstack Class
        3. How It Works
        4. Exercises
      7. Chapter 12 Summary
    22. 13. Easy Programming with STL
      1. Introducing the List Template
        1. Creating and Using a List Class
        2. Creating and Using Iterators
        3. C++11/C++14 Only: For Each
        4. How It Works
        5. A Continually Sorted List
        6. Exercises
      2. Designing an RPN Calculator
        1. Using a Stack for RPN
        2. Introducing the Generalized STL Stack Class
        3. How It Works
        4. Exercises
      3. Correct Interpretation of Angle Brackets
      4. Chapter 13 Summary
    23. 14. Object-Oriented Monty Hall
      1. What’s the Deal?
      2. TV Programming: “Good Deal, Bad Deal”
        1. How It Works
        2. Optimizing the Code
        3. Exercises
        4. How It Works
        5. Exercises
        6. How It Works
        7. Exercises
      3. The Monty Hall Paradox, or What’s Behind the Door?
      4. Improving the Prize Manager
      5. Chapter 14 Summary
    24. 15. Object-Oriented Poker
      1. Winning in Vegas
      2. How to Draw Cards
      3. The Card Class
      4. The Deck Class
      5. Doing the Job with Algorithms
        1. How It Works
        2. Exercises
      6. The Vector Template
      7. Getting Nums from the Player
        1. How It Works
        2. Exercises
      8. How to Evaluate Poker Hands
        1. How It Works
        2. Exercises
      9. Chapter 15 Summary
    25. 16. Polymorphic Poker
      1. Multiple Decks
      2. Switching Decks at Runtime
      3. Polymorphism Is the Answer
        1. How It Works
        2. Exercises
      4. “Pure Virtual” and Other Abstract Matters
      5. Abstract Classes and Interfaces
      6. Object Orientation and I/O
        1. cout Is Endlessly Extensible
        2. But cout Is Not Polymorphic
        3. How It Works
        4. Exercises
      7. A Final Word (or Two)
      8. An (Even More) Final Word
      9. Chapter 16 Summary
    26. 17. New Features of C++14
      1. The Newest C++14 Features
        1. Digit-Group Separators
        2. String-Literal Suffix
        3. Binary Literals
        4. Exercises
      2. Features Introduced in C++11
      3. The long long Type
        1. Working with 64-Bit Literals (Constants)
        2. Accepting long long Input
        3. Formatting long long Numbers
        4. How It Works
        5. Exercises
        6. Localizing Numbers
      4. Range-Based “for” (For Each)
        1. How It Works
        2. Exercises
      5. The auto and decltype Keywords
      6. The nullptr Keyword
      7. Strongly Typed Enumerations
        1. enum Classes in C++11 Onward
        2. Extended enum Syntax: Controlling Storage
      8. Raw-String Literals
      9. Chapter 17 Summary
    27. 18. Operator Functions: Doing It with Class
      1. Introducing Operator Functions
      2. Operator Functions as Global Functions
      3. Improve Efficiency with References
        1. How It Works
        2. Exercises
        3. How It Works
        4. Optimizing the Code
        5. Exercises
      4. Working with Other Types
      5. The Class Assignment Function (=)
      6. The Test-for-Equality Function (==)
      7. A Class “Print” Function
        1. How It Works
        2. Exercises
      8. A Really Final Word (about Ops)
      9. Chapter 18 Summary
    28. A. Operators
      1. The Scope (::) Operator
      2. The sizeof Operator
      3. Old- and New-Style Type Casts
      4. Integer versus Floating-Point Division
      5. Bitwise Operators (&, |, ^, ~, <<, and >>)
      6. Conditional Operator
      7. Assignment Operators
      8. Join (,) Operator
    29. B. Data Types
      1. Precision of Data Types
      2. Data Types of Numeric Literals
      3. String Literals and Escape Sequences
      4. Two’s-Complement Format for Signed Integers
    30. C. Syntax Summary
      1. Basic Expression Syntax
      2. Basic Statement Syntax
      3. Control Structures and Branch Statements
        1. The if-else Statement
        2. The while Statement
        3. The do-while Statement
        4. The for Statement
        5. The switch-case Statement
        6. The break Statement
        7. The continue Statement
        8. The goto Statement
        9. The return Statement
        10. The throw Statement
      4. Variable Declarations
      5. Function Declarations
      6. Class Declarations
      7. Enum Declarations
    31. D. Preprocessor Directives
      1. The #define Directive
      2. The ## Operator (Concatenation)
      3. The defined Function
      4. The #elif Directive
      5. The #endif Directive
      6. The #error Directive
      7. The #if Directive
      8. The #ifdef Directive
      9. The #ifndef Directive
      10. The #include Directive
      11. The #line Directive
      12. The #undef Directive
      13. Predefined Constants
    32. E. ASCII Codes
    33. F. Standard Library Functions
      1. String (C-String) Functions
      2. Data-Conversion Functions
      3. Single-Character Functions
      4. Math Functions
      5. Randomization Functions
      6. Time Functions
      7. Formats for the strftime Function
    34. G. I/O Stream Objects and Classes
      1. Console Stream Objects
      2. I/O Stream Manipulators
      3. Input Stream Functions
      4. Output Stream Functions
      5. File I/O Functions
    35. H. STL Classes and Objects
      1. The STL String Class
      2. The <bitset> Template
      3. The <list> Template
      4. The <vector> Template
      5. The <stack> Template
    36. I. Glossary of Terms
    37. Index
    38. Code Snippets

    Product information

    • Title: C++ Without Fear: A Beginner’s Guide That Makes You Feel Smart, Third Edition
    • Author(s): Brian Overland
    • Release date: December 2015
    • Publisher(s): Pearson
    • ISBN: 9780134319001