Introduction to Programming with C++ for Engineers (true pdf).

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Introduction to Programming with C++ for Engineers is an original presentation teaching the fundamentals of computer programming and modern C++ to engineers and engineering students. 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. Being a textbook, with the summarizing tables and diagrams the book becomes a highly useful reference for C++ programmers at all levels. Introduction to Programming with C++ for Engineers teaches how to program by: Guiding users from simple techniques with modern C++ and the Standard Library, to more advanced object-oriented design methods and language features Providing meaningful examples that facilitate understanding of the programming techniques and the C++ language constructions Fostering good programming practices which create better professional programmers Minimizing text descriptions, opting instead for comprehensive figures, tables, diagrams, and other explanatory material Granting access to a complementary website that contains example code and useful links to resources that further improve the reader’s coding ability Including test and exam question for the reader’s review at the end of each chapter 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++.

Author(s): Boguslaw Cyganek
Edition: 1
Publisher: IEEE Press
Year: 2021

Language: English
Pages: 458
Tags: c++20 c++17 qt

Cover
Title Page
Copyright
Dedication
Contents
Preface
Acknowledgments
Abbreviations
About the Companion Website
Chapter 1 Introduction
1.1 Structure of the Book
1.2 Format Conventions
1.3 About the Code and Projects
Chapter 2 Introduction to Programming
2.1 Hardware Model
2.2 Software Development Ecosystem
2.3 Software Development Steps
2.4 Representing and Running Algorithms
2.4.1 Representing Algorithms
2.4.2 Using Online Compilers
2.4.3 Structure of a C++ Program
2.4.4 Code Analysis
2.4.5 () Building a Linux Executable
2.5 ExampleProject – Compound Interest Calculator
2.5.1 Compound Interest Analysis
2.5.2 Implementation of the Interest Calculator
2.5.3 Building and Running the Software
2.6 Example Project – Counting Occurrences of Characters in Text
2.6.1 Problem Analysis and Implementation
2.6.2 Running the C++ Code with the Online Compiler
2.6.3 Histogram Code, Explained
2.7 Summary
Questions and Exercises
Chapter 3 C++ Basics
3.1 Constants and Variables – Built-In Data Types, Their Range, and Initialization
3.2 Example Project – Collecting Student Grades
3.3 OurFriend the Debugger
3.4 The Basic Data Structure – std : : vector
3.5 Example Project – Implementing a Matrix as a Vector of Vectors
3.6 Special Vector to Store Text – std : : string
3.7 Using the auto Keyword and decltype for Automatic Type Deduction
3.8 Common Standard Algorithms
3.9 Structures: Collecting Objects of Various Types
3.10 () Fixed-Size Arrays
3.10.1 Multidimensional Fixed-Size Arrays
3.11 References
3.12 () Pointers
3.12.1 Object Access with Pointers
3.13 Statements
3.13.1 Blocks of Statements and Access to Variables – The Role of Braces
3.13.2 C++ Statements
3.13.2.1 Conditional Statements
3.13.2.3 Auxiliary Statements – continue and break
3.13.2.4 The goto Statement
3.13.2.5 Structural Exception Handling – The try-catch Statement
3.14 Functions
3.14.1 Anatomy of a Function in C++
3.14.2 Passing Arguments to and from a Function
3.14.2.1 Argument Passing by Copy (Value Semantics
3.14.2.2 Indirect Argument Passing by Reference
3.14.2.3 () Passing by Pointer
3.14.3 Function Call Mechanism and Inline Functions
3.14.4 Recursive Functions and the Call Stack
3.14.5 Function Overloading – Resolving Visibility with Namespaces
3.14.6 Lambda Functions
3.14.7 () More on Lambda Functions
3.14.8 () Function Pointers
3.14.9 () Functions in an Object-Oriented Framework
3.15 Example Project – Wrapping Objects in a Structure with a Constructor
3.15.1 EMatrix in an Object-Oriented Environment
3.15.2 Basic Operations with EMatrix
3.15.3 Input and Output Operations on EMatrix
3.15.4 Basic Mathematical Operations on EMatrix
3.15.5 Organizing the Project Files and Running the Application
3.15.6 Extending Matrix Initialization with a Simple Random Number Generator
3.16 Example Project – Representing Quadratic Equations
3.16.1 Definition of a Class to Represent Quadratic Polynomials
3.16.2 TQuadEq Member Implementation
3.16.3 TQuadEq in Action
3.17 Example Project – Tuples and Structured Bindings for Converting Roman Numerals
3.17.1 More on std : : tuple and the Structured Binding
3.17.2 How to Write a Software Unit Test
3.17.3 Automating Unit Tests – Using the Standard Random Number Library
3.18 Example Project – Building a Currency Calculator Component
3.18.1 Currency Exchange Problem Analysis
3.18.2 CurrencyCalc Software Design
3.18.3 TCurrency Class Representing Currency Records
3.18.3.1 C++ Input/Output Manipulators
3.18.4 TCurrencyExchanger Class for Exchanging Currency
3.18.5 Putting It All Together – The Complete Currency Exchange Program
3.19 Operators
3.19.1 Summary of the C++ Operators
3.19.2 Further Notes on Operators
3.20 Summary
Chapter 4 Delving into Object-Oriented Programming
4.1 Basic Rules and Philosophy of Object-Oriented Design and Programming
4.2 Anatomy of a Class
4.2.1 Naming Conventions and Self-Documenting Code
4.3 Rules for Accessing Class Members
4.4 Example Project – TComplex Class for Operator Overloading
4.4.1 Definition of the TComplex Class
4.4.2 Definition of the TComplex Class Members
4.4.3 Test Functions for the TComplex Class
4.5 Moreon References
4.5.1 Right and Forward References
4.5.2 References vs. Pointers
4.5.3 Pitfalls with References
4.6 Example Project – Mastering Class Members with the TheCube Class
4.6.1 Automatic vs. Explicit Definition of the Constructors
4.6.2 TheCube Object Layout and Semantics
4.6.3 Shallow vs. Deep Copy Semantics
4.6.4 Move Constructor and Move Assignment Semantics
4.6.5 Implementation of the TheCube Streaming Operators
4.6.6 Validation of TheCube
4.7 Example Project – Moving EMatrix to the Class
4.7.1 Definition of the EMatrix Class
4.7.2 Implementation of the Class Streaming Operators
4.7.3 Implementation of the Arithmetic Operators
4.7.4 Testing Matrix Operations
4.8 Introduction to Templates and Generic Programming
4.8.1 Generalizing a Class with Templates
4.8.2 (@) Template Specializations
4.8.3 Template Functions and Type Checking
4.8.4 Example Project – Designing Template Classes with TStack
4.8.4.1 Design and Implementation of the TStackFor Class
4.8.4.2 Testing TStack
4.8.5 Template Member Functions
4.9 Class Relations – “Know,” “Has-A,” and “Is-A"
4.10 Example Project – Extending Functionality Through Class Inheritance with TComplexQuadEq
4.11 Virtual Functions and Polymorphism
4.12 () More on the Virtual Mechanism
4.13 (@) The Curiously Recurring Template Pattern and Static Polymorphism
4.14 (@)Mixin Classes
4.15 Example Project – The TLongNumberFor Class for Efficient Storage of Numbers of Any Length
4.15.1 Binary-Coded Decimal Representation
4.15.2 Endianness
4.15.3 Definition of the TLongNumberFor Class
4.15.3.1 Type-Converting Operations
4.15.3.2 TLongNumberFor Test Function
4.15.4 Designing Classes for PESEL IDs
4.15.4.1 Aggregating PESEL
4.15.4.2 Inherited PESEL
4.15.4.3 LongNumber Project Organization
4.15.5 (@) Extending the Functionality of TLongNumberFor with the Proxy Pattern
4.15.5.1 Definition of the Proxy Class
4.15.5.2 Testing the Functionality of the TLongNumberFor Class with the Proxy Pattern
4.16 Strong Types
4.17 Summary
Questions and Exercises
Chapter 5 Memory Management
5.1 Types of Data Storage
5.2 Dynamic Memory Allocation – How to Avoid Memory Leaks
5.2.1 Introduction to Smart Pointers and Resource Management
5.2.1.1 RAII and Stack Unwinding
5.3 SmartPointers – An Overview with Examples
5.3.1 () More on std : : unique_ptr
5.3.1.1 Context for Using std : : unique_ptr
5.3.1.2 Factory Method Design Pattern
5.3.1.3 Custom deleter for unique_ptr
5.3.1.4 Constructions to Avoid When Using unique_ptr
5.3.2 () More on shared_ptr and weak_ptr
5.4 Summary
Questions and Exercises
Chapter 6 Advanced Object-Oriented Programming
6.1 FunctionalObjects
6.2 Example Project – Extending the Currency Search in XML Files, and Using State Machine and Regular Expressions with the regex Library
6.2.1 Pattern Matching with the Regular Expression Library
6.2.2 State Machine Pattern
6.2.3 Implementing the Extended Class
6.2.4 Project Extension – Loading Currency Information from the Internet
6.2.5 Launching the Extended Version of CurrencyCalc
6.2.6 Building a Static Library and a Terminal Window Application
6.2.7 C++ Filesystem
6.2.8 User Interface
6.2.8.1 Definition of the CC_GUI Class
6.2.8.2 Definitions of Members of the CC_GUI Class and the Callback Mechanism
6.2.8.3 Launching the GUI-Based Application
6.3 System Clocks and Time Measurements
6.4 () Time Measurement for Function Execution
6.5 Range Class
6.5.1 Functional Programming and the Ranges Library
6.6 Example Project – Parsing Expressions
6.6.1 Defining Language Expressions with Formal Grammar Rules
6.6.2 Design of the Expression-Processing Framework
6.6.3 The First Expression Interpreter
6.6.4 Building the Syntax Tree with the Composite Design Pattern
6.6.4.1 The Composite Design Pattern to Define the Nodes of a Tree
6.6.4.2 Implementation of the TNode Hierarchy and Cooperation with Visitors
6.6.4.3 Implementation of the ValueLeafNode Class
6.6.4.4 Implementation of the BinOperator Class
6.6.4.5 Implementation of the PlusOperator Class
6.6.4.6 Deep Copying Node Objects – The Prototyping Mechanism
6.6.5 Interpreter to Build a Syntax Tree
6.6.6 Stack for Smart Pointers
6.6.7 Traversing Trees with the Visitor Design Pattern
6.6.7.1 The Expression-Evaluating Visitor
6.6.7.2 The Expression-Printing Visitor
6.6.8 Testing the Interpreters
6.6.9 Representing Expressions on a Stack in Reverse Polish Notation
6.6.9.1 Reverse Polish Notation
6.6.9.2 Algorithm for Evaluating an RPN Expression
6.7 Summary
Questions and Exercises
Chapter 7 Computer Arithmetic
7.1 Integer Value Representation
7.1.1 Base Conversion Algorithm
7.1.2 Hexadecimal and Octal Representations
7.1.3 Binary Addition
7.1.4 Negative Values and Subtraction
7.1.5 Arithmetic Control Flags
7.1.6 Representing Fractions
7.2 BinaryShift Operations
7.3 () Example Project – Software Model for Fixed-Point Representations
7.3.1 Fixed-Point Numbers and Their Arithmetic
7.3.2 Definition of the FxFor Class
7.3.3 Selected Methods of the FxFor Class
7.3.4 Applications of FxFor
7.4 Floating-Point Representations
7.4.1 Number Representation in Floating-Point Format
7.4.2 Distribution of Floating-Point Numbers and the Computational Consequences
7.4.3 () Real-Value Approximation Error with Floating-Point Representations
7.4.4 The IEEE 754 Standard for Floating-Point Arithmetic
7.4.5 The Standard FP Operation Model
7.4.6 Computations That Are Conscious of Numerical Errors
7.4.7 Example Project – Evaluating the Summation Algorithms
7.4.8 Example Project – The Newton Method of Finding the Roots of a Function
7.4.8.1 Function to Compute Square Roots Based on Newton’s Iteration
7.5 Summary
Questions and Exercises
Chapter 8 Basics of Parallel Programming
8.1 Basic Concepts of Parallel Computations
8.2 Adding Parallelism to the Standard Algorithms
8.3 Launching Asynchronous Tasks
8.4 Parallelization with the OpenMP Library
8.4.1 Launching a Team of Threads and Providing Exclusive Access Protection
8.4.2 Loop Parallelization and Reduction Operations
8.4.3 Massive Data Parallelization
8.4.3 Massive Data Parallelization
8.5 Summary
Questions and Exercises
Appendix
A.1 Preprocess or Directives
A.2 Short Introduction to C
A.2.1 Built-in Arrays
A.2.1.1. Multidimensional Fixed-Size Arrays
A.2.2 Passing Arrays to Functions – The Main Function
A.2.3 C Structures
A.2.4 C Functions and Input/Output
A.2.5 Unions
A.2.6 Memory and String Operations
A.2.7 Binding C and C++ Code
A.3 Linking and Binary Organization of C/C++ Objects
A.4 Graphical User and Web Interfaces for C++ Projects
A.5 Converting Bin, Oct, Dec, and Hex Values with FixBinCalc
A.6 Programming Toolchain
A.6.1 Project-Generating Tool (CMake
A.6.2 Source Version Control and Repositories
A.6.3 Profiler
A.7 Software Testing
A.8 Summary
Questions and Exercises
Bibliography
Index
EULA