Introduction to Programming with C++ for Engineers
Introduction to Programming with C++ for Engineers
Click to enlarge
Author(s): Cyganek, Boguslaw
ISBN No.: 9781119431152
Pages: 656
Year: 202011
Format: E-Book
Price: $ 143.52
Dispatch delay: Dispatched between 7 to 15 days
Status: Available

Preface 8 Acknowledgements 9 1 Intro 11 1.1 Structure of the Book 15 1.2 Format Conventions 17 1.3 About the Code and Projects 19 2 Introduction to Programming 21 2.1 Hardware Model 21 2.2 Software Development Ecosystem 24 2.3 Steps of Software Development 26 2.4 Representing and Running Algorithms 28 2.


4.1 Representing Algorithms 28 2.4.2 Using On-Line Compilers 30 2.4.3 Structure of a C++ Program 31 2.4.4 Code Analysis 32 2.


4.5 (*) Building a Linux Executable 33 2.5 EXAMPLE PROJECT - Compound Interest Calculator 36 2.5.1 Compound Interest Analysis 36 2.5.2 Implementation of the Interest Calculator 37 2.5.


3 Software Building and Testing 40 2.6 EXAMPLE PROJECT - How to Count Occurrences of Characters in a Word? 41 2.6.1 Problem Analysis and the First Code 41 2.6.2 Running the C++ Code with the On-Line Compiler 42 2.6.3 Histogram Code Explained 43 2.


7 Summary 46 2.8 Questions & Exercises 46 3 C++ Basics 48 3.1 Constants and Variables - Built-In Data Types, their Range and Initialization 48 3.2 The Basic Data Structure - std::vector 57 3.3 EXAMPLE PROJECT - Implementing a matrix as a vector of vectors 63 3.4 Special Vector to Store Texts - std::string 65 3.5 Using auto keyword and decltype for automatic type deduction 67 3.6 Common Standard Algorithms 70 3.


7 Structures: Collecting Objects of Various Types 72 3.8 (*) Fixed-size Arrays 76 3.8.1 Multi-dimensional Fixed-Size Arrays 78 3.9 References 79 3.10 (*) Pointers 81 3.10.1 Objects Access with Pointers 81 3.


11 (*) More on References 86 3.11.1 Right and Forward References 86 3.11.2 References vs. Pointers 90 3.11.3 Pitfalls with References 90 3.


12 Statements 92 3.12.1 Blocks of Statements and Access to Variables - The Role of the Braces 92 3.12.2 C++ Statements 95 3.12.2.1 Conditional Statements 95 3.


12.2.2 Loop Statements 99 3.12.2.3 Auxiliary Statements - continue and break 103 3.12.2.


4 The goto Statement 106 3.12.2.5 Structural Exception Handling - the try-catch Statement 107 3.13 Functions 108 3.13.1 Anatomy of a Function in C++ 108 3.13.


2 Passing Arguments to and from a Function 113 3.13.2.1 Argument Passing by Copy (Value Semantics) 113 3.13.2.2 Indirect Argument Passing by Reference 114 3.13.


2.3 (*) Passing by Pointer 116 3.13.3 Function Call Mechanism and Inline Functions 118 3.13.4 Recursive Functions and the Call Stack 119 3.13.5 Function Overloading - Resolving Visibility with Namespaces 120 3.


13.6 Lambda Functions 122 3.13.7 (*) More on Lambda Functions 126 3.13.8 (*) Function Pointers 132 3.13.9 (*) Functions in Object Oriented Framework 133 3.


14 EXAMPLE PROJECT - Wrapping Objects in a Structure with a Constructor 136 3.14.1 EMatrix in Object-Oriented Environment 138 3.14.2 Basic Operations with EMatrix 139 3.14.3 Input and output operations on EMatrix 140 3.14.


4 Basic mathematical operations on EMatrix 142 3.14.5 Organizing the project files and running the application 144 3.14.6 Extending Matrix Initialization with a Simple Random Generator 146 3.15 EXAMPLE PROJECT - Representing Quadratic Equations 147 3.15.1 Definition of a Class to Represent the Quadratic Polynomials 148 3.


15.2 TQuadEq Member Implementation 153 3.15.3 TQuadEq in Action 156 3.16 EXAMPLE PROJECT - Tuples and Structured Bindings for Converting Roman Numbers 158 3.16.1 More on std::tuple and the Structured Binding 160 3.16.


2 How to Write a Software Unit Test? 162 3.16.3 (*) Automating Unit Tests - Using the Standard Random Library 163 3.17 (*) EXAMPLE PROJECT - Building the Currency Calculator Component 165 3.17.1 Currency Exchange Problem Analysis 165 3.17.2 CurrencyCalc Software Design 167 3.


17.3 TCurrency Class to Represent a Currency Record 169 3.17.3.1 C++ Input/Output Manipulators 171 3.17.4 TCurrencyExchanger Class for Currency Exchanging 173 3.17.


5 Putting it All Together - The Complete Program for Currency Exchange 177 3.18 Operators 182 3.18.1 Summary of the C/C++ Operators 185 3.18.2 Further Notes on C/C++ Operators 204 3.19 Summary 205 3.20 Questions & Exercises 206 4 Delving into the Object-Oriented Programming 208 4.


1 Basic Rules and Philosophy of the Object-Oriented Design and Programming 208 4.2 Anatomy of a Class 211 4.2.1 Naming Conventions and Self-Explaining Code 213 4.3 Class Members Access Rules 214 4.4 OPERATOR OVERLOADING - TComplex Class Example 215 4.4.1 Definition of the TComplex Class 216 4.


4.2 Definition of the TComplex Class Members 221 4.4.3 Test Functions for the TComplex Class 223 4.5 Mastering Class Members - TheCube Class Example 225 4.5.1 Automatic vs. explicit definition of the constructors 235 4.


5.2 TheCube Object Layout and Semantics 235 4.5.3 Shallow vs. Deep Copy Semantics 237 4.5.4 Move Constructor and Move Assignment Semantics 237 4.5.


5 Implementation of the TheCube Streaming Operators 239 4.5.6 Validation of TheCube 240 4.6 EXAMPLE PROJECT - Moving EMatrix to the Class 243 4.6.1 Definition of the EMatrix Class 243 4.6.2 Implementation of the Class Streaming Operators 245 4.


6.3 Implementation of the Arithmetic Operators 248 4.6.4 Testing Matrix Operations 250 4.7 Introduction to Templates and Generic Programming 252 4.7.1 (*) Template Specializations 256 4.8 Designing Template Functions and Classes - TStack Example 257 4.


8.1 Design and Implementation of the TStackFor Class 258 4.8.2 Testing TStack 261 4.9 Template Functions and Template Members Function 262 4.10 Class Relations - "Know", "Has-A", "Is-A" Concepts 265 4.11 Extending Functionality through Class Inheritance - TComplexQuadEq Example 272 4.12 Virtual Functions and Polymorphism 277 4.


13 (*) More on Virtual Mechanism 283 4.14 (*) The Curiously Recurring Template Pattern and the Static Polymorphism 285 4.15 EXAMPLE PROJECT - TLongNumberFor Class for Efficient Storage of Numbers of Any Length 289 4.15.1 Binary Coded Decimal Representation 290 4.15.2 Endianness 291 4.15.


3 Definition of the TLongNumberFor Class 292 4.15.3.1 Type Converting Operations 294 4.15.3.2 TLongNumberFor Test Function 298 4.15.


4 Designing Classes for PESEL ID 299 4.15.4.1 Aggregating PESEL 300 4.15.4.2 Inherited PESEL 302 4.15.


4.3 LongNumber Project Organization 303 4.15.5 (*) Extending Functionality of the TLongNumberFor with the Proxy Pattern 304 4.15.5.1 Definition of the Proxy Class 305 4.15.


5.2 Testing Functionality of the TLongNumberFor Class with the Proxy Pattern 307 4.16 Strong Types 309 4.17 Summary 310 4.18 Questions & Exercises 310 5 Memory Management 312 5.1 Data Storage Types 313 5.2 Dynamic Memory Allocations - How to Avoid Memory Leaks 318 5.2.


1 Introduction to Smart Pointers and Resource Management 320 5.2.1.1 RAII and stack unwinding 321 5.3 Smart Pointers - An Overview with Examples 322 5.3.1 (*) More on the std::unique_ptr 328 5.3.


1.1 Context of Using the std::unique_ptr 328 5.3.1.2 Factory Method Design Pattern 331 5.3.1.3 Custom Deleters for the unique_ptr 333 5.


3.1.4 Constructions to Avoid when Using unique_ptr 334 5.3.2 (*) More on shared_ptr and weak_ptr 335 5.4 Summary 337 5.5 Questions & Exercises 337 6 Advancing the Object-Oriented Programming 339 6.1 Functional Objects 339 6.


2 EXAMPLE PROJECT - Extending Currency Search in XML Files - Learning State Machine and Regular Expressions with regex Library 344 6.2.1 Pattern Matching with Regular Expression Library 345 6.2.2 State Machine Pattern 347 6.2.3 Implementation of the Extended Class 348 6.2.


4 Project Extension - Loading Currency Information from the Internet 353 6.2.5 Launching the Extended Version of CurrencyCalc 359 6.2.6 Building a Static Library and a Terminal Window Application 362 6.2.7 C++ Filesystem 364 6.2.


8 User Interface 371 6.2.8.1 Definition of the CC_GUI class 372 6.2.8.2 Definitions of Members of the CC_GUI Class and the Callback Mechanism 375 6.2.


8.3 Launching the GUI Based Application 381 6.3 System Clocks and Time Measurements 383 6.4 (*) Time Measurements of a Function Execution 386 6.5 Range Class 388 6.5.1 Functional Programming & the Ranges Library 393 6.6 EXAMPLE PROJECT - Parsing Expressions 393 6.


6.1 Defining Language Expressions with Formal Grammar Rules 394 6.6.2 Design of the Expression Processing Framework 396 6.6.3 The First Expression Interpreter 397 6.6.4 Building the Syntax Tree with the Composite Design Pattern 401 6.


6.4.1 The Composite Design Pattern to Define Nodes of a Tree 402 6.6.4.2 Implementation of TNode Hierarchy and Cooperation with the Visitors 403 6.6.4.


3 Implementation of the ValueLeafNode Class 405 6.6.4.4 Implementation of the BinOperator Class 406 6.6.4.5 Implementation of the PlusOperator Class 407 6.6.


4.6 Deep Copy of the Node Objects - the Prototyping Mechanism 408 6.6.5 Syntax Tree Building Interpreter 409 6.6.6 Stack for Smart Pointers 414 6.6.7 Traversing the Trees.



To be able to view the table of contents for this publication then please subscribe by clicking the button below...
To be able to view the full description for this publication then please subscribe by clicking the button below...