Skickas på måndag. Fri frakt för medlemmar vid köp för minst 249 kr.
Learn to program with C++ quickly with this helpful For Dummies guide Beginning Programming with C++ For Dummies, 2nd Edition gives you plain-English explanations of the fundamental principles of C++, arming you with the skills and know-how to expertly use one of the world's most popular programming languages. You'll explore what goes into creating a program, how to put the pieces together, learn how to deal with standard programming challenges, and much more.Written by the bestselling author of C++ For Dummies, this updated guide explores the basic development concepts and techniques of C++ from a beginner's point of view, and helps make sense of the how and why of C++ programming from the ground up. Beginning with an introduction to how programming languages function, the book goes on to explore how to work with integer expressions and character expressions, keep errors out of your code, use loops and functions, divide your code into modules, and become a functional programmer. Grasp C++ programming like a pro, even if you've never written a line of codeMaster basic development concepts and techniques in C++Get rid of bugs and write programs that workFind all the code from the book and an updated C++ compiler on the companion websiteIf you're a student or first-time programmer looking to master this object-oriented programming language, Beginning Programming with C++ For Dummies, 2nd Edition has you covered.
Stephen R. Davis is the bestselling author of numerous books and articles, including C++ For Dummies. He has been programming for over 35 years and currently works for Agency Consulting Group in the area of Cyber Defense.
Introduction 1About This Book 1Foolish Assumptions 2How This Book Is Organized 3Part I: Getting Started with C++ Programming 3Part II: Writing a Program: Decisions, Decisions 4Part III: Becoming a Procedural Programmer 4Part IV: Data Structures 4Part V: Object-Oriented Programming 4Part VI: Advanced Strokes 5Part VII: The Part of Tens 5Icons Used in This Book 5Beyond the Book 6Where to Go from Here 6Part I: Getting Started with C++ Programming 7Chapter 1: What Is a Program? 9How Does My Son Differ from a Computer? 9Programming a “Human Computer” 11Creating the algorithm 11Setting the tire-changing language 12Constructing the program 13Computer processors 17Computer Languages 17High-level languages 19The C++ language 20Chapter 2: Installing Code::Blocks 21Reviewing the Compilation Process 21Installing Code::Blocks 23Windows installation 23Ubuntu Linux installation 26Mac OS installation 27Setting up Code::Blocks 31Testing the Code::Blocks Installation 33Creating the project 34Testing your default project 37Chapter 3: Writing Your First Program 41Creating a New Project 41Filename extensions 43Entering Your Program 44Building the Program 46Finding What Could Go Wrong 47Misspelled commands 47Missing semicolon 49Using the Online Material 50Running the Program 51How the Program Works 51The template 51The Conversion program 53Part II: Writing a Program: Decisions, Decisions 55Chapter 4: Integer Expressions 57Declaring Variables 57Variable names 58Assigning a value to a variable 59Initializing a variable at declaration 60Integer Constants 61Expressions 62Binary operators 62Unraveling compound expressions 63Unary Operators 65The Special Assignment Operators 67Chapter 5: Character Expressions 69Defining Character Variables 69Encoding characters 70Example of character encoding 73Encoding Strings of Characters 75Special Character Constants 75Chapter 6: if I Could Make My Own Decisions 79The if Statement 79Comparison operators 80Say “No” to “No braces” 83What Else Is There? 84Nesting if Statements 86Compound Conditional Expressions 89Chapter 7: Switching Paths 93Controlling Flow with the switch Statement 93Control Fell Through: Did I break It? 96Implementing an Example Calculator with the switch Statement 97Chapter 8: Debugging Your Programs, Part I 101Identifying Types of Errors 101Avoiding Introducing Errors 102Coding with style 102Establishing variable naming conventions 103Finding the First Error with a Little Help 104Finding the Run-Time Error 105Formulating test data 106Executing the test cases 106Seeing what’s going on in your program 107Part III: Becoming a Procedural Programmer 109Chapter 9: while Running in Circles 111Creating a while Loop 111Breaking out of the Middle of a Loop 114Nested Loops 117Chapter 10: Looping for the Fun of It 121The for Parts of Every Loop 121Looking at an Example 123Getting More Done with the Comma Operator 125Chapter 11: Functions, I Declare! 129Breaking Your Problem Down into Functions 129Understanding How Functions Are Useful 130Writing and Using a Function 131Returning things 132Reviewing an example 133Passing Arguments to Functions 135Function with arguments 136Functions with multiple arguments 137Exposing main() 137Defining Function Prototype Declarations 139Chapter 12: Dividing Programs into Modules 141Breaking Programs Apart 141Breaking Up Isn’t That Hard to Do 142Creating Factorialcpp 143Creating an #include file 145Including #include files 146Creating maincpp 148Building the result 149Using the Standard C++ Library 149Variable Scope 150Chapter 13: Debugging Your Programs, Par t 2 151Debugging a Dys-Functional Program 151Performing unit level testing 153Outfitting a function for testing 155Returning to unit test 159Part IV: Data Structures 163Chapter 14: Other Numerical Variable Types 165The Limitations of Integers in C++ 165Integer round-off 166Limited range 166A Type That “doubles” as a Real Number 167Solving the truncation problem 168When an integer is not an integer 168Discovering the limits of double 169Variable Size — the “long” and “short” of It 172How far do numbers range? 174Types of Constants 175Passing Different Types to Functions 176Overloading function names 177Mixed-mode overloading 177Chapter 15: Arrays 181What Is an Array? 181Declaring an Array 182Indexing into an Array 183Looking at an Example 184Initializing an Array 187Chapter 16: Arrays with Character 189The ASCII-Zero Character Array 189Declaring and Initializing an ASCIIZ Array 190Looking at an Example 191Looking at a More Detailed Example 193Foiling hackers 197Do I Really Have to Do All That Work? 198Chapter 17: Pointing the Way to C++ Pointers 203What’s a Pointer? 203Declaring a Pointer 204Passing Arguments to a Function 206Passing arguments by value 206Passing arguments by reference 209Putting it together 211Reference argument types 213Playing with Heaps of Memory 214Do you really need a new keyword? 214Don’t forget to clean up after yourself 215Looking at an example 216Chapter 18: Taking a Second Look at C++ Pointers 221Pointers and Arrays 221Operations on pointers 222Pointer addition versus indexing into an array 224Using the pointer increment operator 227Why bother with array pointers? 230Operations on Different Pointer Types 231Constant Nags 231Differences Between Pointers and Arrays 233My main() Arguments 233Arrays of pointers 234Arrays of arguments 235Chapter 19: Programming with Class 241Grouping Data 241The Class 242The Object 243Arrays of Objects 244Looking at an Example 246Chapter 20: Debugging Your Programs, Par t 3 253A New Approach to Debugging 253The solution 254Entomology for Dummies 255Starting the debugger 257Fixing the (first) bug 264Finding and fixing the second bug 265Part V: Object-Oriented Programming 269Chapter 21: What Is Object-Oriented Programming? 271Abstraction and Microwave Ovens 271Procedural nachos 273Object-oriented nachos 273Classification and Microwave Ovens 274Why Build Objects This Way? 275Self-Contained Classes 276Chapter 22: Structured Play: Making Classes Do Things 277Activating Our Objects 277Creating a Member Function 278Defining a member function 279Naming class members 280Calling a member function 281Accessing other members from within a member function 282Keeping a Member Function after Class 284Overloading Member Functions 285Chapter 23: Pointers to Objects 287Pointers to Objects 287Arrow syntax 288Calling all member functions 288Passing Objects to Functions 289Calling a function with an object value 289Calling a function with an object pointer 290Looking at an example 292Allocating Objects off the Heap 296Chapter 24: Do Not Disturb: Protected Members 299Protecting Members 299Why you need protected members 300Making members protected 301So what? 303Who Needs Friends, Anyway? 304Chapter 25: Getting Objects Off to a Good Start 307The Constructor 308Limitations on constructors 309Can I see an example? 310Constructing data members 312Destructors 315Looking at an example 316Destructing data members 318Chapter 26: Making Constructive Arguments 321Constructors with Arguments 321Looking at an example 322Overloading the Constructor 326The Default default Constructor 330Constructing Data Members 332Initializing data members with the default constructor 332Initializing data members with a different constructor 334Looking at an example 337New with C++ 2011 340Chapter 27: Coping with the Copy Constructor 341Copying an Object 341The default copy constructor 342Looking at an example 344Creating a Copy Constructor 346Avoiding Copies 349Part VI: Advanced Strokes 351Chapter 28: Inheriting a Class 353Advantages of Inheritance 354Learning the lingo 355Implementing Inheritance in C++ 355Looking at an example 356Having a HAS_A Relationship 360Chapter 29: Are Virtual Functions for Real? 361Overriding Member Functions 361Early binding 362Ambiguous case 364Enter late binding 366When Is Virtual Not? 369Virtual Considerations 371Chapter 30: Overloading Assignment Operators 373Overloading an Operator 374Overloading the Assignment Operator Is Critical 374Looking at an Example 376Writing Your Own (or Not) 379Chapter 31: Performing Streaming I/O 381How Stream I/O Works 381Stream Input/Output 383Creating an input object 383Creating an output object 385Open modes 386What is binary mode? 386Hey, file, what state are you in? 387Other Member Functions of the fstream Classes 391Reading and writing streams directly 393Controlling format 396What’s up with endl? 399Manipulating Manipulators 399Using the stringstream Classes 400Chapter 32: I Take Exception! 405The Exception Mechanism 406Examining the exception mechanism in detail 408Special considerations for throwing 409Creating a Custom Exception Class 410Restrictions on exception classes 414Part VII: The Part of Tens 415Chapter 33: Ten Ways to Avoid Bugs 417Enable All Warnings and Error Messages 417Adopt a Clear and Consistent Coding Style 418Comment the Code While You Write It 419Single-Step Every Path in the Debugger at Least Once 419Limit the Visibility 420Keep Track of Heap Memory 420Zero Out Pointers after Deleting What They Point To 421Use Exceptions to Handle Errors 421Declare Destructors Virtual 422Provide a Copy Constructor and Overloaded Assignment Operator 422Chapter 34: Ten Features Not Covered in This Book 423The goto Command 423The Ternary Operator 424Binary Logic 425Enumerated Types 425Namespaces 425Pure Virtual Functions 426The string Class 426Multiple Inheritance 427Templates and the Standard Template Library 427Lambda Functions 428Index 429