Cover ....1
Title....4
Copyright ....5
Contents ....8
Preface ....14
Acknowledgments ....16
Chapter 1 C++ and Beyond....18
Introduction....18
1.1 The Origin of C++....18
1.2 Why Use C++?....19
1.3 Various Programming Paradigms....20
1.3.1 Structural Programming....20
1.3.2 Procedural Programming....21
1.3.3 Object Oriented Programming....21
1.4 C++ Basics ....24
1.4.1 Variables ....24
1.4.2 Data Types ....25
1.4.3 Data Modifiers ....26
1.t C++ Execution Flow ....28
Summary ....30
Exercises ....31
Theory Questions....31
MCQ-Based....31
Practical Application....33
References ....34
Books ....34
Websites ....34
Chapter 2 Basic Play in C++....36
2.1 Literals, Constants, and Qualifiers....36
2.2 Stream-Based IO....37
2.3 Comments ....39
2.4 Operators and Types....40
2.4.1 Types of Operators in C++....40
2.5 Type Conversion ....42
2.6 Keywords ....44
2.7 Loops in C++ ....45
2.9 Control Statements ....49
2.9 Defining Functions ....53
2.9.1 Why Use Functions?....53
2.10 C vs. C++....54
Summary ....55
Exercises ....56
Theory Questions....56
MCQ-Based....56
Practical Questions ....58
References ....59
Books ....59
Websites ....59
Chapter 3 Arrays and Strings....60
3.1 What is an Array?....60
3.1.1 Ways to Declare Arrays....60
3.1.2 Ways to Access Array Members....61
3.1.3 Traversing a 1D Array ....62
3.2 Operations on an Array....62
3.2.1 Passing an Array to Functions....62
3.2.2 Finding the Length ....63
3.2.3 Enum in C++ ....64
3.2.4 Searching ....65
3.3 Multi-Dimensional Array ....68
3.4 Strings ....69
3.5 String Functions ....70
Summary ....71
Exercises ....71
Theory Questions ....71
MCQ-Based ....72
Practical Questions....73
References ....74
Books ....74
Websites ....74
Chapter 4 Pointers in C++ ....76
4.1 Introduction ....76
4.2 Pointers: Declaration and Initialization....76
4.3 Casting and Passing Pointers....80
4.3.1 Typecasting....80
4.3.2 Passing....81
4.4 Using Pointers with Arrays ....83
4.5 Pointer Use....87
Summary ....88
Exercises ....89
Theory Questions ....89
Practical Questions ....89
MCQ-Based ....90
References ....92
Books ....92
Websites ....92
Chapter 5 Classes in C++....94
5.1 Class Making....94
5.2 Constructors and Destructors....96
5.3 The This Pointer....103
5.4 Class Methods....104
5.5 The static Keyword ....106
5.6 Memory Management and Garbage Collection in C++....107
Summary ....109
Exercises ....109
Theory Questions ....109
Practical Questions ....110
MCQ-Based....110
References ....112
Books ....112
Websites ....112
Chapter 6 Inheritance ....114
6.1 Introduction ....114
6.2 Inheritance ....114
6.2.1 Access Specifiers ....116
6.2.2 Inheritance Modes....118
6.3 Types of Inheritance....124
6.4 Constructor Calling ....141
6.5 Implementing Inheritance....142
Summary ....144
Exercises ....145
Theory Questions ....145
Practial Questions ....145
MCQ-Based ....146
References ....153
Books ....153
Websites ....154
Chapter 7 Polymorphism....156
7.1 Introduction ....156
7.2 Dynamic vs. Static Binding ....159
7.3 Interface and Implementation....162
7.4 Function Overriding and Overloading ....166
7.5 Friend and Generic Functions ....170
7.5.1 Friend Functions ....170
7.5.2 Generic Functions....172
7.6 Namespaces....174
Summary ....176
Exercises ....177
Theory Questions....177
Practical Questions ....177
MCQ-Based ....178
References ....183
Books ....183
Websites ....183
Chapter 8 Operator Overloading ....184
8.1 Basics ....184
8.2 How to Overload an Operator?....185
8.3 Overloading Unary Operators....188
8.4 Overloading Binary Operators....191
8.5 Overloading by Friend Function....196
Summary ....197
Exercises ....198
Theory Questions ....198
Practical Questions....198
MCQ-Based....199
References ....203
Books ....203
Websites ....203
Chapter 9 Structure and Union....204
9.1 Structure: Declaration and Definition ....204
9.2 Accessing a Structure ....207
9.3 Union ....209
9.4 Differences Between Structure and Union....211
9.5 Enum in C++....212
Summary ....214
Exercises ....214
Theory Questions....214
Practical Questions ....215
MCQ-Based....215
References ....231
Books ....231
Websites ....231
Chapter 10 Exception Handling ....232
10.1 Errors and Exceptions....232
10.2 Exception Handling....235
10.3 Various Exceptions....237
10.4 Custom Exceptions in C++....238
Summary ....240
Exercises ....241
Theory Questions ....241
Practical Questions ....241
MCQ-Based....242
References ....263
Books ....263
Websites ....263
Chapter 11 File Handling....264
11.1 Files and Streams ....264
11.2 File Operations ....267
11.3 Random Access and Object Serialization....270
Summary ....272
Exercises ....273
Theory Questions....273
Practical Questions....273
MCQ-Based ....274
References ....285
Books ....285
Websites ....285
Index ....286
This book is designed to cover the basics of C++, the powerful programming language used by developers all over the world. Its readily understandable concepts and easy syntax areused in video games, embedded systems, IoT devices, and resource-heavy AI applications. Using a “self-teaching” method with numerous examples and figures, the book covers all of the major C++ concepts, including pointers, classes, strings, arrays, polymorphism, inheritance, file handling, and more. Various types of the end of chapter exercises include theoretical, practical, and multiple choice (with answers) to enhance comprehension of the topics covered.