Details

Introduction to Programming with C++ for Engineers


Introduction to Programming with C++ for Engineers


IEEE Press 1. Aufl.

von: Boguslaw Cyganek

77,99 €

Verlag: Wiley
Format: PDF
Veröffentl.: 23.11.2020
ISBN/EAN: 9781119431176
Sprache: englisch
Anzahl Seiten: 656

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

Beschreibungen

<p><b>A complete textbook and reference for engineers to learn the fundamentals of computer programming with modern C++</b></p> <p><i>Introduction to Programming with C++ for Engineers</i> is an original presentation teaching the fundamentals of computer programming and modern C++ to engineers and engineering students. </p> <p>Professor Cyganek, a highly regarded expert in his field, walks users through basics of data structures and algorithms with the help of a core subset of C++ and the Standard Library, progressing to the object-oriented domain and advanced C++ features, computer arithmetic, memory management and essentials of parallel programming, showing with real world examples how to complete tasks. He also guides users through the software development process, good programming practices, not shunning from explaining low-level features and the programming tools.</p> <p>Being a textbook, with the summarizing tables and diagrams the book becomes a highly useful reference for C++ programmers at all levels.</p> <p><i>Introduction to Programming with C++ for Engineers </i>teaches how to program by:</p> <ul> <li>Guiding users from simple techniques with modern C++ and the Standard Library, to more advanced object-oriented design methods and language features</li> <li>Providing meaningful examples that facilitate understanding of the programming techniques and the C++ language constructions</li> <li>Fostering good programming practices which create better professional programmers</li> <li>Minimizing text descriptions, opting instead for comprehensive figures, tables, diagrams, and other explanatory material</li> <li>Granting access to a complementary website that contains example code and useful links to resources that further improve the reader’s coding ability</li> <li>Including test and exam question for the reader’s review at the end of each chapter</li> </ul> <p>Engineering students, students of other sciences who rely on computer programming, and professionals in various fields will find this book invaluable when learning to program with C++.</p>
<p>Preface xi</p> <p>Acknowledgments xiii</p> <p>Abbreviations xv</p> <p>About the Companion Website xvii</p> <p><b>1 Introduction 1</b></p> <p>1.1 Structure of the Book 5</p> <p>1.2 Format Conventions 8</p> <p>1.3 About the Code and Projects 9</p> <p><b>2 Introduction to Programming 13</b></p> <p>2.1 Hardware Model 13</p> <p>2.2 Software Development Ecosystem 16</p> <p>2.3 Software Development Steps 18</p> <p>2.4 Representing and Running Algorithms 20</p> <p>2.4.1 Representing Algorithms 21</p> <p>2.4.2 Using Online Compilers 22</p> <p>2.4.3 Structure of a C++ Program 24</p> <p>2.4.4 Code Analysis 24</p> <p>2.4.5 Building a Linux Executable 26</p> <p>2.5 Example Project – Compound Interest Calculator 29</p> <p>2.5.1 Compound Interest Analysis 29</p> <p>2.5.2 Implementation of the Interest Calculator 30</p> <p>2.5.3 Building and Running the Software 33</p> <p>2.6 Example Project – Counting Occurrences of Characters in Text 34</p> <p>2.6.1 Problem Analysis and Implementation 34</p> <p>2.6.2 Running the C++ Code with the Online Compiler 35</p> <p>2.6.3 Histogram Code, Explained 36</p> <p>2.7 Summary 39</p> <p>Questions and Exercises 39</p> <p><b>3 C++ Basics 43</b></p> <p>3.1 Constants and Variables – Built-In Data Types, Their Range, and Initialization 43</p> <p>3.2 Example Project – Collecting Student Grades 53</p> <p>3.3 Our Friend the Debugger 56</p> <p>3.4 The Basic Data Structure – std::vector 59</p> <p>3.5 Example Project – Implementing a Matrix as a Vector of Vectors 64</p> <p>3.6 Special Vector to Store Text – std::string 67</p> <p>3.7 Using the auto Keyword and decltype for Automatic Type Deduction 72</p> <p>3.8 Common Standard Algorithms 75</p> <p>3.9 Structures: Collecting Objects of Various Types 79</p> <p>3.10 Fixed-Size Arrays 83</p> <p>3.10.1 Multidimensional Fixed-Size Arrays 85</p> <p>3.11 References 87</p> <p>3.12 Pointers 90</p> <p>3.12.1 Object Access with Pointers 90</p> <p>3.13 Statements 95</p> <p>3.13.1 Blocks of Statements and Access to Variables – The Role of Braces 95</p> <p>3.13.2 C++ Statements 97</p> <p>3.13.2.1 Conditional Statements 97</p> <p>3.13.2.2 Loop Statements 103</p> <p>3.13.2.3 Auxiliary Statements – continue and break 108</p> <p>3.13.2.4 The goto Statement 110</p> <p>3.13.2.5 Structural Exception Handling – The try-catch Statement 110</p> <p>3.14 Functions 112</p> <p>3.14.1 Anatomy of a Function in C++ 112</p> <p>3.14.2 Passing Arguments to and from a Function 117</p> <p>3.14.2.1 Argument Passing by Copy (Value Semantics) 118</p> <p>3.14.2.2 Indirect Argument Passing by Reference 119</p> <p>3.14.2.3 Passing by Pointer 121</p> <p>3.14.3 Function Call Mechanism and Inline Functions 123</p> <p>3.14.4 Recursive Functions and the Call Stack 125</p> <p>3.14.5 Function Overloading – Resolving Visibility with Namespaces 126</p> <p>3.14.6 Lambda Functions 128</p> <p>3.14.7 More on Lambda Functions 132</p> <p>3.14.8 Function Pointers 138</p> <p>3.14.9 Functions in an Object-Oriented Framework 140</p> <p>3.15 Example Project – Wrapping Objects in a Structure with a Constructor 142</p> <p>3.15.1 EMatrix in an Object-Oriented Environment 145</p> <p>3.15.2 Basic Operations with EMatrix 145</p> <p>3.15.3 Input and Output Operations on EMatrix 147</p> <p>3.15.4 Basic Mathematical Operations on EMatrix 148</p> <p>3.15.5 Organizing the Project Files and Running the Application 150</p> <p>3.15.6 Extending Matrix Initialization with a Simple Random Number Generator 153</p> <p>3.16 Example Project – Representing Quadratic Equations 154</p> <p>3.16.1 Definition of a Class to Represent Quadratic Polynomials 155</p> <p>3.16.2 TQuadEq Member Implementation 162</p> <p>3.16.3 TQuadEq in Action 165</p> <p>3.17 Example Project – Tuples and Structured Bindings for Converting Roman Numerals 167</p> <p>3.17.1 More on std::tuple and the Structured Binding 170</p> <p>3.17.2 How to Write a Software Unit Test 173</p> <p>3.17.3 Automating Unit Tests – Using the Standard Random Number Library 174</p> <p>3.18 Example Project – Building a Currency Calculator Component 176</p> <p>3.18.1 Currency Exchange Problem Analysis 177</p> <p>3.18.2 CurrencyCalc Software Design 179</p> <p>3.18.3 TCurrency Class Representing Currency Records 181</p> <p>3.18.3.1 C++ Input/Output Manipulators 183</p> <p>3.18.4 TCurrencyExchanger Class for Exchanging Currency 186</p> <p>3.18.5 Putting It All Together – The Complete Currency Exchange Program 190</p> <p>3.19 Operators 196</p> <p>3.19.1 Summary of the C++ Operators 199</p> <p>3.19.2 Further Notes on Operators 222</p> <p>3.20 Summary 223</p> <p>Questions and Exercises 224</p> <p><b>4 Delving into Object-Oriented Programming 227</b></p> <p>4.1 Basic Rules and Philosophy of Object-Oriented Design and Programming 227</p> <p>4.2 Anatomy of a Class 231</p> <p>4.2.1 Naming Conventions and Self-Documenting Code 233</p> <p>4.3 Rules for Accessing Class Members 233</p> <p>4.4 Example Project – TComplex Class for Operator Overloading 235</p> <p>4.4.1 Definition of the TComplex Class 236</p> <p>4.4.2 Definition of the TComplex Class Members 241</p> <p>4.4.3 Test Functions for the TComplex Class 243</p> <p>4.5 More on References 246</p> <p>4.5.1 Right and Forward References 246</p> <p>4.5.2 References vs. Pointers 251</p> <p>4.5.3 Pitfalls with References 252</p> <p>4.6 Example Project – Mastering Class Members with the TheCube Class 253</p> <p>4.6.1 Automatic vs. Explicit Definition of the Constructors 254</p> <p>4.6.2 TheCube Object Layout and Semantics 264</p> <p>4.6.3 Shallow vs. Deep Copy Semantics 265</p> <p>4.6.4 Move Constructor and Move Assignment Semantics 266</p> <p>4.6.5 Implementation of the TheCube Streaming Operators 267</p> <p>4.6.6 Validation of TheCube 269</p> <p>4.7 Example Project – Moving EMatrix to the Class 272</p> <p>4.7.1 Definition of the EMatrix Class 272</p> <p>4.7.2 Implementation of the Class Streaming Operators 274</p> <p>4.7.3 Implementation of the Arithmetic Operators 278</p> <p>4.7.4 Testing Matrix Operations 279</p> <p>4.8 Introduction to Templates and Generic Programming 281</p> <p>4.8.1 Generalizing a Class with Templates 282</p> <p>4.8.2 Template Specializations 286</p> <p>4.8.3 Template Functions and Type Checking 287</p> <p>4.8.4 Example Project – Designing Template Classes with TStack 289</p> <p>4.8.4.1 Design and Implementation of the TStackFor Class 290</p> <p>4.8.4.2 Testing TStack 293</p> <p>4.8.5 Template Member Functions 294</p> <p>4.9 Class Relations – “Know,” “Has-A,” and “Is-A” 297</p> <p>4.10 Example Project – Extending Functionality Through Class Inheritance with TComplexQuadEq 304</p> <p>4.11 Virtual Functions and Polymorphism 310</p> <p>4.12 More on the Virtual Mechanism 316</p> <p>4.13 The Curiously Recurring Template Pattern and Static Polymorphism 318</p> <p>4.14 Mixin Classes 322</p> <p>4.15 Example Project – The TLongNumberFor Class for Efficient Storage of Numbers of Any Length 323</p> <p>4.15.1 Binary-Coded Decimal Representation 325</p> <p>4.15.2 Endianness 326</p> <p>4.15.3 Definition of the TLongNumberFor Class 326</p> <p>4.15.3.1 Type-Converting Operations 329</p> <p>4.15.3.2 TLongNumberFor Test Function 333</p> <p>4.15.4 Designing Classes for PESEL IDs 335</p> <p>4.15.4.1 Aggregating PESEL 336</p> <p>4.15.4.2 Inherited PESEL 337</p> <p>4.15.4.3 LongNumber Project Organization 338</p> <p>4.15.5 Extending the Functionality of TLongNumberFor with the Proxy Pattern 340</p> <p>4.15.5.1 Definition of the Proxy Class 341</p> <p>4.15.5.2 Testing the Functionality of the TLongNumberFor Class with the Proxy Pattern 343</p> <p>4.16 Strong Types 345</p> <p>4.17 Summary 346</p> <p>Questions and Exercises 346</p> <p><b>5 Memory Management 349</b></p> <p>5.1 Types of Data Storage 349</p> <p>5.2 Dynamic Memory Allocation – How to Avoid Memory Leaks 349</p> <p>5.2.1 Introduction to Smart Pointers and Resource Management 358</p> <p>5.2.1.1 RAII and Stack Unwinding 359</p> <p>5.3 Smart Pointers – An Overview with Examples 360</p> <p>5.3.1 More on std::unique_ptr 360</p> <p>5.3.1.1 Context for Using std::unique_ptr 360</p> <p>5.3.1.2 Factory Method Design Pattern 374</p> <p>5.3.1.3 Custom deletes for unique_ptr 376</p> <p>5.3.1.4 Constructions to Avoid When Using unique_ptr 378</p> <p>5.3.2 More on shared_ptr and weak_ptr 378</p> <p>5.4 Summary 381</p> <p>Questions and Exercises 381</p> <p><b>6 Advanced Object-Oriented Programming 383</b></p> <p>6.1 Functional Objects 383</p> <p>6.2 Example Project – Extending the Currency Search in XML Files, and Using State Machine and Regular Expressions with the regex Library 389</p> <p>6.2.1 Pattern Matching with the Regular Expression Library 390</p> <p>6.2.2 State Machine Pattern 392</p> <p>6.2.3 Implementing the Extended Class 393</p> <p>6.2.4 Project Extension – Loading Currency Information from the Internet 399</p> <p>6.2.5 Launching the Extended Version of CurrencyCalc 405</p> <p>6.2.6 Building a Static Library and a Terminal Window Application 409</p> <p>6.2.7 C++ Filesystem 410</p> <p>6.2.8 User Interface 419</p> <p>6.2.8.1 Definition of the CC_GUI Class 420</p> <p>6.2.8.2 Definitions of Members of the CC_GUI Class and the Callback Mechanism 423</p> <p>6.2.8.3 Launching the GUI-Based Application 430</p> <p>6.3 System Clocks and Time Measurements 431</p> <p>6.4 Time Measurement for Function Execution 435</p> <p>6.5 Range Class 437</p> <p>6.5.1 Functional Programming and the Ranges Library 442</p> <p>6.6 Example Project – Parsing Expressions 443</p> <p>6.6.1 Defining Language Expressions with Formal Grammar Rules 444</p> <p>6.6.2 Design of the Expression-Processing Framework 446</p> <p>6.6.3 The First Expression Interpreter 447</p> <p>6.6.4 Building the Syntax Tree with the Composite Design Pattern 451</p> <p>6.6.4.1 The Composite Design Pattern to Define the Nodes of a Tree 452</p> <p>6.6.4.2 Implementation of the TNode Hierarchy and Cooperation with Visitors 453</p> <p>6.6.4.3 Implementation of the ValueLeafNode Class 455</p> <p>6.6.4.4 Implementation of the BinOperator Class 457</p> <p>6.6.4.5 Implementation of the PlusOperator Class 458</p> <p>6.6.4.6 Deep Copying Node Objects – The Prototyping Mechanism 459</p> <p>6.6.5 Interpreter to Build a Syntax Tree 460</p> <p>6.6.6 Stack for Smart Pointers 466</p> <p>6.6.7 Traversing Trees with the Visitor Design Pattern 469</p> <p>6.6.7.1 The Expression-Evaluating Visitor 472</p> <p>6.6.7.2 The Expression-Printing Visitor 474</p> <p>6.6.8 Testing the Interpreters 476</p> <p>6.6.9 Representing Expressions on a Stack in Reverse Polish Notation 479</p> <p>6.6.9.1 Reverse Polish Notation 479</p> <p>6.6.9.2 Algorithm for Evaluating an RPN Expression 480</p> <p>6.7 Summary 485</p> <p>Questions and Exercises 485</p> <p><b>7 Computer Arithmetic 489</b></p> <p>7.1 Integer Value Representation 489</p> <p>7.1.1 Base Conversion Algorithm 491</p> <p>7.1.2 Hexadecimal and Octal Representations 492</p> <p>7.1.3 Binary Addition 493</p> <p>7.1.4 Negative Values and Subtraction 494</p> <p>7.1.5 Arithmetic Control Flags 496</p> <p>7.1.6 Representing Fractions 498</p> <p>7.2 Binary Shift Operations 501</p> <p>7.3 Example Project – Software Model for Fixed-Point Representations 503</p> <p>7.3.1 Fixed-Point Numbers and Their Arithmetic 503</p> <p>7.3.2 Definition of the FxFor Class 504</p> <p>7.3.3 Selected Methods of the FxFor Class 510</p> <p>7.3.4 Applications of FxFor 516</p> <p>7.4 Floating-Point Representations 519</p> <p>7.4.1 Number Representation in Floating-Point Format 520</p> <p>7.4.2 Distribution of Floating-Point Numbers and the Computational Consequences 524</p> <p>7.4.3 Real-Value Approximation Error with Floating-Point Representations 527</p> <p>7.4.4 The IEEE 754 Standard for Floating-Point Arithmetic 530</p> <p>7.4.5 The Standard FP Operation Model 537</p> <p>7.4.6 Computations That Are Conscious of Numerical Errors 537</p> <p>7.4.7 Example Project – Evaluating the Summation Algorithms 539</p> <p>7.4.8 Example Project – The Newton Method of Finding the Roots of a Function 544</p> <p>7.4.8.1 Function to Compute Square Roots Based on Newton’s Iteration 548</p> <p>7.5 Summary 550</p> <p>Questions and Exercises 551</p> <p><b>8 Basics of Parallel Programming 553</b></p> <p>8.1 Basic Concepts of Parallel Computations 553</p> <p>8.2 Adding Parallelism to the Standard Algorithms 556</p> <p>8.3 Launching Asynchronous Tasks 559</p> <p>8.4 Parallelization with the OpenMP Library 561</p> <p>8.4.1 Launching a Team of Threads and Providing Exclusive Access Protection 562</p> <p>8.4.2 Loop Parallelization and Reduction Operations 564</p> <p>8.4.3 Massive Data Parallelization 567</p> <p>8.5 Summary 575</p> <p>Questions and Exercises 575</p> <p><b>Appendix 577</b></p> <p>A.1 Preprocessor Directives 577</p> <p>A.2 Short Introduction to C 582</p> <p>A.2.1 Built‐in Arrays 583</p> <p>A.2.1.1 Multidimensional Fixed-Size Arrays 585</p> <p>A.2.2 Passing Arrays to Functions – The Main Function 586</p> <p>A.2.3 C Structures 590</p> <p>A.2.4 C Functions and Input/Output 591</p> <p>A.2.5 Unions 592</p> <p>A.2.6 Memory and String Operations 593</p> <p>A.2.7 Binding C and C++ Code 599</p> <p>A.3 Linking and Binary Organization of C/C++ Objects 599</p> <p>A.4 Graphical User and Web Interfaces for C++ Projects 601</p> <p>A.5 Converting Bin, Oct, Dec, and Hex Values with FixBinCalc 603</p> <p>A.6 Programming Toolchain 604</p> <p>A.6.1 Project-Generating Tool (CMake) 604</p> <p>A.6.2 Source Version Control and Repositories 609</p> <p>A.6.3 Profiler 610</p> <p>A.7 Software Testing 612</p> <p>A.8 Summary 616</p> <p>Questions and Exercises 616</p> <p>Bibliography 619</p> <p>Index 623</p>
<p><b>Prof. Boguslaw Cyganek, Department of Electronics, AGH, University of Science and Technology, Krakow, Poland</b>. Boguslaw Cyganek obtained his Ph.D. degree cum laude in 2001 with a thesis on correlation of stereo images, and D.Sc. degree in 2011 with a thesis on methods and algorithms of object recognition in digital images. During recent years, Dr. Cyganek has been cooperating with many scientific centers in development of computer vision systems. He has also gained several years of practical experience working as a Software Development Manager and a Senior Software Engineer both in the USA and Poland. He is an author or a co-author of over ninety conference and journal papers and four books including "An Introduction to 3D Computer Vision Techniques and Algorithms", as well as "Object Detection and Recognition in Digital Images: Theory and Practice", published by Wiley. Dr. Cyganek is a member of the IEEE, SPIE, IAPR and SIAM.</p>
<p><b>A complete reference for engineers to learn the fundamentals of C and C++ programming</b> <p><i>Introduction to Programming with C++ for Engineers</i> is an original presentation teaching the fundamentals of both C and C++ to engineers and engineering students. With a focus on providing a quick but manageable learning curve for programming novices, this book provides comprehensive lessons in object-oriented programming in C and C++. <p>Professor Cyganek, a highly regarded expert in his field, walks users through the basics of C and C++ programming simultaneously, showing with real world examples how to complete tasks in both languages. He also guides users through the installation process of the C and C++ programming environments in both Linux and Windows. <p><i>Introduction to Programming with C++ for Engineers</i> teaches novices how to program by: <ul> <li>Granting access to a complementary website that contains example code and useful links to resources that further improve the reader's coding ability</li> <li>Minimizing text descriptions, opting instead for figures, tables, diagrams, and other explanatory material</li> <li>Covering C++20</li> <li>Including test and exam questions for the reader's review at the end of each chapter</li> </ul> <p>Engineering students, students of other sciences who rely on computer programming, and professionals in various fields will find this book invaluable when first learning to program in C and C++.

Diese Produkte könnten Sie auch interessieren:

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