Details

Beginning Programming with C++ For Dummies


Beginning Programming with C++ For Dummies


2. Aufl.

von: Stephen R. Davis

22,99 €

Verlag: Wiley
Format: PDF
Veröffentl.: 07.10.2014
ISBN/EAN: 9781118823897
Sprache: englisch
Anzahl Seiten: 464

DRM-geschütztes eBook, Sie benötigen z.B. Adobe Digital Editions und eine Adobe ID zum Lesen.

Beschreibungen

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

Diese Produkte könnten Sie auch interessieren:

Domain Architectures
Domain Architectures
von: Daniel J. Duffy
PDF ebook
31,99 €