Welcome to the CppInsights repository, your go-to destination for unraveling the mysteries of C++ programming. Here, Weβve put together clear, easy-to-understand examples that explain the core concepts and rules of C++.
Organized into branches, each branch of this repository is dedicated to a specific aspect of C++, facilitating easy navigation and focused learning. Whether you're a new or an experienced developer, our examples are tailored to help you grasp complex concepts and refine your C++ skills.
Each branch serves as a guided tour through the realm of C++, empowering you to unlock the language's full potential and embark on a rewarding programming journey. Join us as we explore into the depths of C++, one concept at a time. Happy coding!
-
Computers execute commands given by programmers, who write programs in languages like C++, each with its own rules. Programs are translated from high-level human-readable code to low-level instructions by compilers, with files linked together to form an executable. Errors are common in programming, and understanding them is crucial for effective troubleshooting:
- Compiler Errors
- Linker Errors
- Runtime Errors
- Logic Errors
-
We will explore the structure of a C++ program, which consists of a series of instructions that are executed sequentially. The program consists of multiple types of instructions that shape its structure, we will cover the following:
- Preprocessor Directives
- Comments
main()Function- Namespaces
- Basic Input/Output
-
Variables and constants are used to store data in a program, with variables being mutable and constants being immutable. We will cover the following:
- Variable Declaration
- Variable Initialization
- Variables Types
- Constants
-
Arrays and vectors are used to store multiple values of the same type in a single variable. We will cover the following:
- Arrays
- Vectors
- Multidimensional Arrays & Vectors
-
Statements and operators are used to perform operations on data in a program. We will cover the following:
- Statements
- Expressions
- Operators
- Operator Precedence
- Compound Assignment Operators
-
Controlling program flow is essential for executing specific instructions based on conditions. We will cover the following:
- Block Statements
- Variable Scope
- Selection Statements
ifStatementsif-elseStatements- ... and more
- Iteration Statements
forloopswhileloops- ... and more
-
Characters and strings are used to represent textual data in a program. We will cover the following:
- Characters
- Strings
- C-Style Strings
- C++ Strings
-
Functions are used to encapsulate a set of instructions that perform a specific task. We will cover the following:
- Function Definition
- Function Prototypes
- Function Parameters
- Return Statements
- Default Arguments
- Overloading Functions
- Passing Arrays to Functions
- Passing by Reference
- Scope Rules
- How Functions Work
- Inline Functions
-
Pointers and references are used to store memory addresses and access data indirectly. We will cover the following:
- Pointer Declaration & Initialization
- Accessing Pointers & Storing Addresses
- Dereferencing Pointers
- Dynamic Memory Allocation
- Relationship Between Pointers & Arrays
- Pointer Arithmetic
- Constants & Pointers
- Pointers & Functions
- Potiential Pointer Pitfalls
-
Object-Oriented Programming (OOP) is a programming paradigm that uses objects to model real-world entities. We will cover the following:
- What is Object-Oriented Programming?
- What are Classes & Objects?
- Declaring Classes and creating Objects
- Accessing Class Members
- Public & Private Access Specifiers
- Implementing Class Functions
- Constructors & Destructors
- Constructor initializer lists
- Delegating Constructors
- Constructor parameters with default values
- Copy Constructor
- Move Constructor
- The
thisPointer - Static Class Members & Functions
- Structs vs Classes
- Friend Functions & Classes
-
Operator overloading allows operators to be redefined for user-defined types. We will cover the following:
- Why operator overloading?
- Overloading the assignment operator (Copy)
- Overloading the assignment operator (Move)
- Overloading operators as Member Functions
- Overloading operators as Global Functions
- Overloading the stream insertion and extraction operators
-
Inheritance is a mechanism that allows a class to inherit properties and behaviors from another class. We will cover the following:
- Key Concepts in Inheritance
- Inheritance vs Composition
- Deriving class from existing class
- Protected Members and Class Access
- Access Control Table
- Constructors and Destructors in Inheritance
- Passing Arguments to Base Class Constructors
- Copy/Move Constructors and Assignment Operators in Inheritance
- Redefining Base Methods
- Multiple Inheritance
-
Polymorphism is a feature that allows objects to be treated as instances of their parent class. We will cover the following:
- What is Polymorphism?
- Static vs Dynamic Polymorphism
- Base Class Pointers or References
- Virtual Functions
- Virtual Destructor
overridekeywordfinalkeyword- Pure Virtual & Abstract Classes
-
Smart pointers are objects that manage the memory of dynamically allocated objects. We will cover the following:
- Why were smart pointers introduced?
- What are smart pointers?
- key features of smart pointers
- RAII (Resource Acquisition Is Initialization)
std::unique_ptrstd::shared_ptrstd::weak_ptr- Custom Deleters