C++ All-in-One For Dummies - John Paul Mueller - ebook

C++ All-in-One For Dummies ebook

John Paul Mueller

0,0
124,99 zł

Opis

Get ahead of the C++ curve to stay in the game C++ is the workhorse of programming languages and remains one ofthe most widely used programming languages today. It'scross-platform, multi-functional, and updates are typicallyopen-source. The language itself is object-oriented, offering youthe utmost control over data usage, interface, and resourceallocation. If your job involves data, C++ proficiency makes youindispensable. C++ All-in-One For Dummies, 3rd Edition is yournumber-one handbook to C++ mastery. Author John Paul Mueller is arecognized authority in the computer industry, and your ultimateguide to C++. Mueller takes you through all things C++, includinginformation relevant to the 2014 update. * Learn how to work with objects and classes * Conquer advanced programming and troubleshooting * Discover how lambda expressions can make your code more conciseand readable * See Standard Library features, such as dynamic arrays, inaction Online resources include source code from examples in the bookas well as a C++ GNU compiler. If you need to learn C++, this isthe fastest, most effective way to do it. C++ All-in-One ForDummies, 3rd Edition will get you up and running quickly, soyou can get to work producing code faster and better than ever.

Ebooka przeczytasz w aplikacjach Legimi na:

Androidzie
iOS
czytnikach certyfikowanych
przez Legimi
Windows
10
Windows
Phone

Liczba stron: 1224




C++ All-in-One For Dummies®, 3rd Edition

Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com

Copyright © 2014 by John Wiley & Sons, Inc., Hoboken, New Jersey

Published simultaneously in Canada

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.

Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.

LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.

For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit www.wiley.com/techsupport.

Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.

Library of Congress Control Number: 2014935515

ISBN: 978-1-118-82378-1 (pbk); ISBN 978-1-118-82379-8 (ebk); ISBN 978-1-118-82385-9 (ebk)

Manufactured in the United States of America

10 9 8 7 6 5 4 3 2 1

C++ All-in-One For Dummies®, 3rd Edition

Visit www.dummies.com/cheatsheet/cplusplusaio to view this book's cheat sheet.

Table of Contents

Introduction

No Experience Necessary

Great for Advanced Folks, Too!

For All Computers

Conventions

Organization

Icons Galore

What’s Next?

Beyond the Book

Book I: Getting Started with C++

Chapter 1: Configuring Your System

Obtaining a Copy of C++ 14

Obtaining Code::Blocks

Installing Code::Blocks

Working with Windows

Working with Mac OS/X

Using the standard Linux installation

Using the graphical Linux installation

Touring the Essential Code::Blocks Features

Starting Code::Blocks for the first time

Opening the sample projects

Viewing the essential windows

Using Other IDEs

Chapter 2: Creating Your First C++ Application

Code::Blocks Creating a Project

Understanding projects

Defining your first project

Building and executing your first application

Typing the Code

Starting with Main

Showing Information

Doing some math

Tabbing your output

Let Your Application Run Away

Chapter 3: Storing Data in C++

Putting Your Data Places: Variables

Creating an integer variable

Declaring multiple variables

Changing values

Setting one variable equal to another

Initializing a variable

Creating a great name for yourself

Manipulating Integer Variables

Adding integer variables

Subtracting integer variables

Multiplying integer variables

Dividing integer variables

Characters

Null character

Nonprintable and other cool characters

Strings

Getting a part of a string

Changing part of a string

Adding onto a string

Adding two strings

Deciding between Conditional Operators

Telling the Truth with Boolean Variables

Reading from the Console

Chapter 4: Directing the Application Flow

Doing This or Doing That

Evaluating Conditions in C++

Finding the right C++ operators

Combining multiple evaluations

Including Evaluations in C++ Conditional Statements

Deciding what if and also what else

Going further with the else and if

Repeating Actions with Statements That Loop

Looping situations

Looping for

Looping while

Doing while

Breaking and continuing

Nesting loops

Chapter 5: Dividing Your Work with Functions

Dividing Your Work

Calling a Function

Passing a variable

Passing multiple variables

Writing Your Own Functions

Multiple parameters or no parameters

Returning nothing

Keeping your variables local

Forward references and function prototypes

Writing two versions of the same function

Calling All String Functions

Understanding main()

Chapter 6: Splitting Up Source Code Files

Creating Multiple Source Files

Splitting a project into multiple source files in Code::Blocks

Creating a project in Code::Blocks with multiple existing files

Multiple source files in other compilers

Creating multiple files

Sharing with Header Files

Adding the header only once

Using brackets or quotes

Sharing Variables among Source Files

Using the Mysterious Header Wrappers

Chapter 7: Referring to Your Data Through Pointers

Heaping and Stacking the Variables

Getting a variable’s address

Changing a variable by using a pointer

Pointing at a string

Pointing to something else

Tips on pointer variables

Dynamically Allocating with new

Using new

Using an initializer

Making new strings

Freeing Pointers

Passing Pointer Variables to Functions

Changing variable values with pointers

Modifying string parameters

Returning Pointer Variables from Functions

Returning a Pointer as a Nonpointer

Passing by Reference

Passing By const Reference

Remembering the Rules

Chapter 8: Working with Classes

Understanding Objects and Classes

Classifying classes and objects

Describing member functions and data

Implementing a class

Separating member function code

The parts of a class

Working with a Class

Accessing members

Using classes and pointers

Passing objects to functions

Using const parameters in functions

Using the this pointer

Overloading member functions

Starting and Ending with Constructors and Destructors

Starting with constructors

Ending with destructors

Sampling constructors and destructors

Adding parameters to constructors

Building Hierarchies of Classes

Creating a hierarchy in C++

Understanding types of inheritance

Creating and Using Object Aliases

Chapter 9: Using Advanced C++ Features

Filling Your Code with Comments

Converting Types

Reading from the Console

Understanding Preprocessor Directives

Using Constants

Using Switch Statements

Supercharging enums with Classes

Working with Random Numbers

Storing Data in Arrays

Declaring and accessing an array

Arrays of pointers

Passing arrays to functions

Adding and subtracting pointers

Book II: Understanding Objects and Classes

Chapter 1: Planning and Building Objects

Recognizing Objects

Observing the Mailboxes class

Observing the Mailbox class

Finding other objects

Encapsulating Objects

Building Hierarchies

Establishing a hierarchy

Protecting members when inheriting

Overriding member functions

Specializing with polymorphism

Getting abstract about things

Discovering Classes

Engineering your software

Finding those pesky classes

Chapter 2: Describing Your Program with UML

Moving Up to UML

Modeling with UML

Diagramming and designing with UML

Building with UML and the Rational Unified Process

Speaking iteratively

Phasing in and out

The inception phase

The elaboration phase

The construction phase

The transition phase

Moving Forward with UML

Chapter 3: Structuring Your Classes with UML

Drawing Classes

Mapping classes with UML

Inheriting in UML

Aggregating and composing classes

Building Components

Deploying the Software

Chapter 4: Demonstrating Behavior with UML

Drawing Objects

Casing Out the Use Cases

Expanding use cases

Matching use cases and requirements

Sequence Diagrams

Notating sequence diagrams

Looping and comparing in sequence diagrams

Collaboration Diagrams

Activity Diagrams

State Diagrams

Chapter 5: Modeling Your Applications with UML

Using UML Goodies

Packaging your symbols

Notating your diagrams

Tagging your symbols

Free to Be UML

C++ and UML

Drawing enumerations

Including static members

Parameterizing classes with templates

Chapter 6: Building with Design Patterns

Introducing a Simple Pattern: the Singleton

Watching an Instance with an Observer

Observers and the Standard C++ Library

Automatically adding an observer

Mediating with a Pattern

Book III: Fixing Problems

Chapter 1: Dealing with Bugs

It’s Not a Bug. It’s a Feature!

Make Your Application Features Look Like Features

Anticipating (Almost) Everything

Avoiding Mistakes, Plain and Simple

Chapter 2: Debugging an Application

Programming with Debuggers

Running the debugger

Recognizing the parts of the Code::Blocks debugger

Debugging with Different Tools

Standard debuggers

Debugging a Code::Blocks Application with Command Line Arguments

Chapter 3: Stopping and Inspecting Your Code

Setting and Disabling Breakpoints

Setting a breakpoint in Code::Blocks

Enabling and disabling breakpoints

Watching, Inspecting, and Changing Variables

Watching the variables

Watching objects

Changing values

Chapter 4: Traveling About the Stack

Stacking Your Data

Moving about the stack

Storing local variables

Debugging with Advanced Features

Viewing threads

Tracing through assembly code

Book IV: Advanced Programming

Chapter 1: Working with Arrays, Pointers, and References

Building Up Arrays

Declaring arrays

Arrays and pointers

Using multidimensional arrays

Arrays and command-line parameters

Allocating an array on the heap

Storing arrays of pointers and arrays of arrays

Building constant arrays

Pointing with Pointers

Becoming horribly complex

Pointers to functions

Pointing a variable to a member function

Pointing to static member functions

Referring to References

Reference variables

Returning a reference from a function

Chapter 2: Creating Data Structures

Working with Data

The great variable roundup

Expressing variables from either side

Casting a spell on your data

Casting safely with C++

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!

Lesen Sie weiter in der vollständigen Ausgabe!