O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C++ For Dummies, 7th Edition

Book Description

The best-selling C++ For Dummies book makes C++ easier!

C++ For Dummies, 7th Edition is the best-selling C++ guide on the market, fully revised for the 2014 update. With over 60% new content, this updated guide reflects the new standards, and includes a new Big Data focus that highlights the use of C++ among popular Big Data software solutions. The book provides step-by-step instruction from the ground up, helping beginners become programmers and allowing intermediate programmers to sharpen their skills. The companion website provides all code mentioned in the text, an updated GNU_C++, the new C++ compiler, and other applications. By the end of the first chapter, you will have programmed your first C++ application!

As one of the most commonly used programming languages, C++ is a must-have skill for programmers who wish to remain versatile and marketable. C++ For Dummies, 7th Edition provides clear, concise, expert instruction, which is organized for easy navigation and designed for hands-on learning. Whether you're new to programming, familiar with other languages, or just getting up to speed on the new libraries, features, and generics, this guide provides the information you need.

  • Provides you with an introduction to C++ programming

  • Helps you become a functional programmer

  • Features information on classes, inheritance, and optional features

  • Teaches you 10 ways to avoid adding bugs

  • The book incorporates the newest C++ features into the fundamental instruction, allowing beginners to learn the update as they learn the language. Staying current on the latest developments is a crucial part of being a programmer, and C++ For Dummies, 7th Edition gets you started off on the right foot.

    Table of Contents

      1. Introduction
        1. About This Book
        2. Icons Used in This Book
        3. Beyond the Book
        4. Where to Go from Here
      2. Part I: Getting Started with C++ Programming
        1. Chapter 1: Writing Your First C++ Program
          1. Grasping C++ Concepts
          2. Installing Code::Blocks
            1. Windows
            2. Ubuntu Linux
            3. Macintosh
          3. Creating Your First C++ Program
            1. Creating a project
            2. Entering the C++ code
            3. Cheating
            4. Building your program
          4. Executing Your Program
          5. Reviewing the Annotated Program
            1. Examining the framework for all C++ programs
            2. Clarifying source code with comments
            3. Basing programs on C++ statements
            4. Writing declarations
            5. Generating output
          6. Calculating Expressions
            1. Storing the results of an expression
            2. Examining the remainder of Conversion
        2. Chapter 2: Declaring Variables Constantly
          1. Declaring Variables
          2. Declaring Different Types of Variables
            1. Reviewing the limitations of integers in C++
            2. Solving the truncation problem
            3. Looking at the limits of floating point numbers
          3. Declaring Variable Types
            1. Types of constants
            2. Range of Numeric Types
            3. Special characters
          4. Wide Loads on Char Highway
          5. Are These Calculations Really Logical?
          6. Mixed Mode Expressions
          7. Automatic Declarations
        3. Chapter 3: Performing Mathematical Operations
          1. Performing Simple Binary Arithmetic
          2. Decomposing Expressions
          3. Determining the Order of Operations
          4. Performing Unary Operations
          5. Using Assignment Operators
        4. Chapter 4: Performing Logical Operations
          1. Why Mess with Logical Operations?
          2. Using the Simple Logical Operators
            1. Storing logical values
            2. Using logical int variables
            3. Be careful performing logical operations on floating-point variables
          3. Expressing Binary Numbers
            1. The decimal number system
            2. Other number systems
            3. The binary number system
          4. Performing Bitwise Logical Operations
            1. The single-bit operators
            2. Using the bitwise operators
            3. A simple test
        5. Chapter 5: Controlling Program Flow
          1. Controlling Program Flow with the Branch Commands
          2. Executing Loops in a Program
            1. Looping while a condition is true
            2. Using the autoincrement/autodecrement feature
            3. Using the for loop
            4. Avoiding the dreaded infinite loop
            5. For each his own
            6. Applying special loop controls
          3. Nesting Control Commands
          4. Switching to a Different Subject?
      3. Part II: Becoming a Functional C++Programmer
        1. Chapter 6: Creating Functions
          1. Writing and Using a Function
            1. Defining our first function
            2. Defining the sumSequence() function
            3. Calling the function sumSequence()
            4. Divide and conquer
          2. Understanding the Details of Functions
            1. Understanding simple functions
            2. Understanding functions with arguments
          3. Overloading Function Names
          4. Defining Function Prototypes
          5. Defaulting Arguments
          6. Passing by Value and Passing by Reference
          7. Variable Storage Types
        2. Chapter 7: Storing Sequences in Arrays
          1. Arraying the Arguments for Arrays
            1. Using an array
            2. Initializing an array
            3. Accessing too far into an array
            4. Arraying range-based for loops
            5. Defining and using arrays of arrays
          2. Using Arrays of Characters
            1. Creating an array of characters
            2. Creating a string of characters
          3. Manipulating Strings with Character
          4. Adding Some Library Functions
          5. Making Room for Wide Strings
        3. Chapter 8: Taking a First Look at C++ Pointers
          1. Variable Size
          2. What’s in an Address?
          3. Address Operators
          4. Using Pointer Variables
            1. Using different types of pointers
          5. Passing Pointers to Functions
            1. Passing by value
            2. Passing pointer values
            3. Passing by reference
          6. Constant const Irritation
          7. Making Use of a Block of Memory Called the Heap
            1. Limited scope
            2. Examining the scope problem
            3. Providing a solution using the heap
        4. Chapter 9: Taking a Second Look at C++ Pointers
          1. Defining Operations on Pointer Variables
            1. Reexamining arrays in light of pointer variables
            2. Applying operators to the address of an array
            3. Expanding pointer operations to a string
            4. Justifying pointer-based string manipulation
            5. Applying operators to pointer types other than char
            6. Contrasting a pointer with an array
          2. When Is a Pointer Not?
          3. Declaring and Using Arrays of Pointers
            1. Utilizing arrays of character strings
            2. Accessing the arguments to main()
        5. Chapter 10: The C++ Preprocessor
          1. What Is a Preprocessor?
          2. Including Files
          3. #Defining Things
            1. Okay, how about not #defining things?
            2. Enumerating other options
          4. Including Things #if I Say So
          5. Intrinsically Defined Objects
          6. Typedef
      4. Part III: Introduction to Classes
        1. Chapter 11: Examining Object-Oriented Programming
          1. Abstracting Microwave Ovens
            1. Preparing functional nachos
            2. Preparing object-oriented nachos
          2. Classifying Microwave Ovens
          3. Why Classify?
        2. Chapter 12: Adding Class to C++
          1. Introducing the Class
          2. The Format of a Class
          3. Accessing the Members of a Class
          4. Activating Our Objects
            1. Simulating real-world objects
            2. Why bother with member functions?
          5. Adding a Member Function
          6. Calling a Member Function
            1. Accessing other members from a member function
          7. Scope Resolution (And I Don’t Mean How Well Your Telescope Works)
          8. Defining a Member Function in the Class
          9. Keeping a Member Function after Class
          10. Overloading Member Functions
        3. Chapter 13: Point and Stare at Objects
          1. Declaring Arrays of Objects
          2. Declaring Pointers to Objects
            1. Dereferencing an object pointer
            2. Pointing toward arrow pointers
          3. Passing Objects to Functions
            1. Calling a function with an object value
            2. Calling a function with an object pointer
            3. Calling a function by using the reference operator
          4. Why Bother with Pointers or References?
          5. Returning to the Heap
            1. Allocating heaps of objects
            2. When memory is allocated for you
          6. Linking Up with Linked Lists
            1. Performing other operations on a linked list
            2. Hooking up with a LinkedListData program
          7. Ray of Hope: A List of Containers Linked to the C++ Library
        4. Chapter 14: Protecting Members: Do Not Disturb
          1. Protecting Members
            1. Why you need protected members
            2. Discovering how protected members work
          2. Making an Argument for Using Protected Members
            1. Protecting the internal state of the class
            2. Using a class with a limited interface
          3. Giving Non-member Functions Access to Protected Members
        5. Chapter 15: “Why Do You Build Me Up, Just toTear Me Down, Baby?”
          1. Creating Objects
          2. Using Constructors
            1. Constructing a single object
            2. Constructing multiple objects
            3. Constructing a duplex
          3. Dissecting a Destructor
            1. Why you need the destructor
            2. Working with destructors
        6. Chapter 16: Making Constructive Arguments
          1. Outfitting Constructors with Arguments
            1. Using a constructor
          2. Placing Too Many Demands on the Carpenter: Overloading the Constructor
          3. Defaulting Default Constructors
          4. Constructing Class Members
            1. Constructing a complex data member
            2. Constructing a constant data member
          5. Reconstructing the Order of Construction
            1. Local objects construct in order
            2. Static objects construct only once
            3. All global objects construct before main()
            4. Global objects construct in no particular order
            5. Members construct in the order in which they are declared
            6. Destructors destruct in the reverse order of the constructors
          6. Constructing Arrays
          7. Constructors as a Form of Conversion
        7. Chapter 17: The Copy/Move Constructor
          1. Copying an Object
            1. Why you need the copy constructor
            2. Using the copy constructor
          2. The Automatic Copy Constructor
          3. Creating Shallow Copies versus Deep Copies
          4. It’s a Long Way to Temporaries
            1. Avoiding temporaries, permanently
            2. The move constructor
        8. Chapter 18: Static Members: Can Fabric Softener Help?
          1. Defining a Static Member
            1. Why you need static members
            2. Using static members
            3. Referencing static data members
            4. Uses for static data members
          2. Declaring Static Member Functions
          3. What Is this About Anyway?
      5. Part IV: Inheritance
        1. Chapter 19: Inheriting a Class
          1. Do I Need My Inheritance?
          2. How Does a Class Inherit?
            1. Using a subclass
            2. Constructing a subclass
            3. Destructing a subclass
            4. Inheriting constructors
          3. Having a HAS_A Relationship
        2. Chapter 20: Examining Virtual Member Functions: Are They for Real?
          1. Why You Need Polymorphism
          2. How Polymorphism Works
          3. When Is a Virtual Function Not?
          4. Considering Virtual Considerations
        3. Chapter 21: Factoring Classes
          1. Factoring
          2. Implementing Abstract Classes
            1. Describing the abstract class concept
            2. Making an honest class out of an abstract class
            3. Passing abstract classes
      6. Part V: Security
        1. Chapter 22: A New Assignment Operator, Should You Decide to Accept It
          1. Comparing Operators with Functions
          2. Inserting a New Operator
          3. Creating Shallow Copies Is a Deep Problem
          4. Overloading the Assignment Operator
          5. Overloading the Subscript Operator
          6. The Move Constructor and Move Operator
        2. Chapter 23: Using Stream I/O
          1. How Stream I/O Works
            1. Default stream objects
          2. Stream Input/Output
            1. Open modes
            2. Hey, file, what state are you in?
            3. Can you show me an example?
          3. Other Methods of the Stream Classes
            1. Reading and writing streams directly
            2. Controlling format
            3. What's up with endl?
            4. Positioning the pointer within a file
          4. Using the stringstream Subclasses
          5. Manipulating Manipulators
        3. Chapter 24: Handling Errors — Exceptions
          1. Justifying a New Error Mechanism?
          2. Examining the Exception Mechanism
          3. What Kinds of Things Can I Throw?
          4. Just Passing Through
        4. Chapter 25: Inheriting Multiple Inheritance
          1. Describing the Multiple Inheritance Mechanism
          2. Straightening Out Inheritance Ambiguities
          3. Adding Virtual Inheritance
          4. Constructing the Objects of Multiple Inheritance
          5. Voicing a Contrary Opinion
        5. Chapter 26: Tempting C++ Templates
          1. Generalizing a Function into a Template
          2. Class Templates
          3. Tips for Using Templates
          4. External Template Instantiations
          5. Implementing an Initializer List
        6. Chapter 27: Standardizing on the Standard Template Library
          1. The string Container
          2. Iterating through Lists
            1. Making your way through a list
            2. Operations on an entire list
            3. Can you show me an example?
        7. Chapter 28: Writing Hacker-Proof Code
          1. Understanding the Hacker's Motives
          2. Understanding Code Injection
            1. Examining an example SQL injection
            2. Avoiding code injection
          3. Overflowing Buffers for Fun and Profit
            1. Can I see an example?
            2. How does a call stack up?
            3. Hacking BufferOverflow
            4. Avoiding buffer overflow — first attempt
            5. Avoiding buffer overflow — second attempt
            6. Another argument for the string class
            7. Why not always use string functions?
      7. Part VI: The Part of Tens
        1. Chapter 29: Ten Ways to Avoid Adding Bugs to Your Program
          1. Enable All Warnings and Error Messages
          2. Adopt a Clear and Consistent Coding Style
          3. Limit the Visibility
          4. Comment Your Code While You Write It
          5. Single-Step Every Path at Least Once
          6. Avoid Overloading Operators
          7. Manage the Heap Systematically
          8. Use Exceptions to Handle Errors
          9. Declare Destructors Virtual
          10. Avoid Multiple Inheritance
        2. Chapter 30: Ten Ways to Protect Your Programs from Hackers
          1. Don't Make Assumptions about User Input
          2. Handle Failures Gracefully
          3. Maintain a Program Log
          4. Follow a Good Development Process
          5. Implement Good Version Control
          6. Authenticate Users Securely
          7. Manage Remote Sessions
          8. Obfuscate Your Code
          9. Sign Your Code With a Digital Certificate
          10. Use Secure Encryption Wherever Necessary
      8. About the Author
      9. Cheat Sheet
      10. More Dummies Products