Embarking on the journey to learn a programming language can be both exciting and challenging. Among the plethora of options available, C++ stands out as a powerful, versatile, and highly sought-after language. Whether you are a complete beginner or an experienced programmer looking to expand your skillset, mastering C++ opens doors to a wide range of opportunities in software development, game programming, system design, and much more.
LearnCpp.com offers a free and extensive resource dedicated to teaching modern C++. Their well-structured tutorials are designed to guide you through every step of the process, from writing your first lines of code to understanding advanced C++ concepts. No prior programming knowledge is assumed, making it an ideal starting point for novices, while seasoned coders can also benefit from the best practices, tips, and in-depth explanations provided.
This guide serves as an overview of the LearnCpp.com curriculum, outlining the chapters and topics covered to help you navigate your learning path effectively. It’s your roadmap to mastering the C++ programming language.
Chapter 0: Introduction / Getting Started
This foundational chapter lays the groundwork for your C++ learning experience. It introduces you to the world of programming and sets the stage for your coding journey.
- 0.1 Introduction to these tutorials: Get acquainted with the LearnCpp.com tutorial series and what you can expect to learn.
- 0.2 Introduction to programs and programming languages: Understand the fundamental concepts of programs and the role of programming languages.
- 0.3 Introduction to C/C++: Discover the history and evolution of C and C++, and their significance in the programming landscape.
- 0.4 Introduction to C++ development: Explore the C++ development process and the tools you’ll need.
- 0.5 Introduction to the compiler, linker, and libraries: Learn about the essential components that transform your code into executable programs.
- 0.6 Installing an Integrated Development Environment (IDE): Set up your coding environment by installing an IDE, making code writing and management easier.
- 0.7 Compiling your first program: Write, compile, and run your very first C++ program – a milestone in your learning!
- 0.8 A few common C++ problems: Become aware of common pitfalls that beginners often encounter and how to avoid them.
- 0.9 Configuring your compiler: Build configurations: Learn how to configure your compiler for different build scenarios.
- 0.10 Configuring your compiler: Compiler extensions: Understand compiler extensions and how they can expand C++ capabilities.
- 0.11 Configuring your compiler: Warning and error levels: Customize compiler warnings and error levels to improve code quality and catch issues early.
- 0.12 Configuring your compiler: Choosing a language standard: Learn about different C++ language standards and how to choose the right one for your projects.
- 0.13 What language standard is my compiler using?: Determine the C++ standard your compiler is currently using.
Chapter 1: C++ Basics
Chapter 1 delves into the fundamental building blocks of C++ programming, starting with program structure and basic syntax.
- 1.1 Statements and the structure of a program: Understand how C++ programs are organized and how statements form the basis of program execution.
- 1.2 Comments: Learn to use comments effectively to annotate your code for better readability and understanding.
- 1.3 Introduction to objects and variables: Grasp the concepts of objects and variables, which are essential for storing and manipulating data.
- 1.4 Variable assignment and initialization: Master how to assign values to variables and initialize them properly.
- 1.5 Introduction to iostream: cout, cin, and endl: Learn to use
iostream
for basic input and output operations usingcout
,cin
, andendl
. - 1.6 Uninitialized variables and undefined behavior: Understand the dangers of uninitialized variables and how to avoid undefined behavior in your programs.
- 1.7 Keywords and naming identifiers: Familiarize yourself with C++ keywords and rules for naming identifiers effectively.
- 1.8 Whitespace and basic formatting: Learn the importance of whitespace and proper code formatting for readability.
- 1.9 Introduction to literals and operators: Explore literals and operators, the basic tools for performing operations on data.
- 1.10 Introduction to expressions: Understand how expressions are constructed and evaluated in C++.
- 1.11 Developing your first program: Put your knowledge into practice by developing a simple C++ program.
- 1.x Chapter 1 summary and quiz: Review and test your understanding of the concepts covered in Chapter 1.
Chapter 2: C++ Basics: Functions and Files
Building upon the basics, Chapter 2 introduces functions and file organization, crucial for creating modular and reusable code.
- 2.1 Introduction to functions: Learn about the power of functions in breaking down complex tasks into smaller, manageable units.
- 2.2 Function return values (value-returning functions): Understand how functions can return values and how to utilize them in your programs.
- 2.3 Void functions (non-value returning functions): Explore functions that perform actions without returning a specific value.
- 2.4 Introduction to function parameters and arguments: Learn how to pass data to functions using parameters and arguments.
- 2.5 Introduction to local scope: Understand the concept of local scope and how it affects variable accessibility within functions.
- 2.6 Why functions are useful, and how to use them effectively: Discover the benefits of using functions and best practices for effective function design.
- 2.7 Forward declarations and definitions: Learn about forward declarations and how they enable the use of functions before their full definition.
- 2.8 Programs with multiple code files: Organize larger projects by splitting code into multiple files for better management and compilation.
- 2.9 Naming collisions and an introduction to namespaces: Understand naming collisions and how namespaces help prevent them in larger projects.
- 2.10 Introduction to the preprocessor: Explore the C++ preprocessor and its role in code compilation.
- 2.11 Header files: Learn to use header files to share declarations and definitions across multiple code files.
- 2.12 Header guards: Implement header guards to prevent multiple inclusions and compilation errors.
- 2.13 How to design your first programs: Gain insights into designing and structuring your first C++ programs effectively.
- 2.x Chapter 2 summary and quiz: Review and assess your grasp of functions and file handling in C++.
Chapter 3: Debugging C++ Programs
Debugging is an essential skill for any programmer. This chapter equips you with the tools and techniques to identify and fix errors in your C++ code.
- 3.1 Syntax and semantic errors: Differentiate between syntax and semantic errors and understand common error types.
- 3.2 The debugging process: Learn a systematic approach to debugging, making error resolution more efficient.
- 3.3 A strategy for debugging: Develop a strategic mindset for tackling debugging challenges effectively.
- 3.4 Basic debugging tactics: Explore fundamental debugging techniques like print statements and code inspection.
- 3.5 More debugging tactics: Expand your debugging toolkit with advanced tactics for complex issues.
- 3.6 Using an integrated debugger: Stepping: Learn to use an integrated debugger and master the technique of stepping through code execution.
- 3.7 Using an integrated debugger: Running and breakpoints: Utilize breakpoints to pause program execution and examine variables at specific points.
- 3.8 Using an integrated debugger: Watching variables: Monitor variable values during debugging to track program state.
- 3.9 Using an integrated debugger: The call stack: Understand the call stack and how it helps in tracing function calls and errors.
- 3.10 Finding issues before they become problems: Learn proactive techniques to prevent bugs from occurring in the first place.
- 3.x Chapter 3 summary and quiz: Review and solidify your debugging skills in C++.
Chapter 4: Fundamental Data Types
Data types are the foundation of data manipulation in programming. Chapter 4 introduces the fundamental data types in C++.
- 4.1 Introduction to fundamental data types: Get an overview of the basic data types available in C++ for representing different kinds of data.
- 4.2 Void: Understand the
void
type and its special uses in C++. - 4.3 Object sizes and the sizeof operator: Learn how to determine the size of objects in memory using the
sizeof
operator. - 4.4 Signed integers: Explore signed integers and their range of values.
- 4.5 Unsigned integers, and why to avoid them: Understand unsigned integers and the common pitfalls associated with their use.
- 4.6 Fixed-width integers and size_t: Learn about fixed-width integers for platform-independent size and
size_t
for representing sizes. - 4.7 Introduction to scientific notation: Understand scientific notation for representing floating-point numbers.
- 4.8 Floating point numbers: Explore floating-point numbers and their precision considerations.
- 4.9 Boolean values: Learn about boolean values (
true
andfalse
) and their use in logical operations. - 4.10 Introduction to if statements: Begin control flow learning with
if
statements for conditional execution. - 4.11 Chars: Understand character data type (
char
) and how to work with characters. - 4.12 Introduction to type conversion and static_cast: Learn about type conversion and safe explicit type casting using
static_cast
. - 4.x Chapter 4 summary and quiz: Review and reinforce your understanding of fundamental data types in C++.
Chapter 5: Constants and Strings
Constants and strings are essential for representing fixed values and textual data. Chapter 5 covers these important concepts.
- 5.1 Constant variables (named constants): Learn to define and use constant variables for values that should not change.
- 5.2 Literals: Explore different types of literals in C++ for representing constant values directly in code.
- 5.3 Numeral systems (decimal, binary, hexadecimal, and octal): Understand different numeral systems and how they are used in programming.
- 5.4 The as-if rule and compile-time optimization: Discover how compilers optimize code based on the “as-if” rule.
- 5.5 Constant expressions: Understand constant expressions that are evaluated at compile time.
- 5.6 Constexpr variables: Learn about
constexpr
variables and their benefits for compile-time computation. - 5.7 Introduction to std::string: Begin working with
std::string
, the standard C++ string class for efficient string manipulation. - 5.8 Introduction to std::string_view: Explore
std::string_view
for efficient read-only access to strings without copying. - 5.9 std::string_view (part 2): Dive deeper into
std::string_view
and its advanced features. - 5.x Chapter 5 summary and quiz: Review and test your knowledge of constants and strings in C++.
Chapter 6: Operators
Operators are the actions you can perform on data. Chapter 6 provides a comprehensive overview of C++ operators.
- 6.1 Operator precedence and associativity: Understand operator precedence and associativity to correctly interpret complex expressions.
- 6.2 Arithmetic operators: Master arithmetic operators for performing mathematical calculations.
- 6.3 Remainder and Exponentiation: Learn about the remainder operator and techniques for exponentiation.
- 6.4 Increment/decrement operators, and side effects: Understand increment and decrement operators and their potential side effects.
- 6.5 The comma operator: Explore the comma operator and its specific use cases.
- 6.6 The conditional operator: Learn to use the conditional operator as a shorthand for
if-else
statements. - 6.7 Relational operators and floating point comparisons: Understand relational operators and special considerations for comparing floating-point numbers.
- 6.8 Logical operators: Master logical operators (
AND
,OR
,NOT
) for combining conditions. - 6.x Chapter 6 summary and quiz: Review and solidify your understanding of operators in C++.
Chapter O: Bit Manipulation (optional chapter)
For those interested in lower-level programming and optimization, Chapter O (Optional) delves into bit manipulation.
- O.1 Bit flags and bit manipulation via std::bitset: Learn to use
std::bitset
for managing bit flags and performing bit manipulation. - O.2 Bitwise operators: Explore bitwise operators for direct manipulation of individual bits.
- O.3 Bit manipulation with bitwise operators and bit masks: Master bit manipulation techniques using bitwise operators and bit masks.
- O.4 Converting integers between binary and decimal representation: Understand how to convert between binary and decimal representations of integers.
Chapter 7: Scope, Duration, and Linkage
Chapter 7 explores the concepts of scope, duration, and linkage, which are crucial for managing variables and functions in larger programs.
- 7.1 Compound statements (blocks): Understand compound statements (blocks) and their role in defining scope.
- 7.2 User-defined namespaces and the scope resolution operator: Learn to create and use namespaces to organize code and avoid naming conflicts.
- 7.3 Local variables: Understand local variables and their scope within functions or blocks.
- 7.4 Introduction to global variables: Explore global variables and their scope across the entire program.
- 7.5 Variable shadowing (name hiding): Understand variable shadowing and potential issues when names are reused in different scopes.
- 7.6 Internal linkage: Learn about internal linkage and how it restricts visibility to the current translation unit.
- 7.7 External linkage and variable forward declarations: Understand external linkage and how to share variables across multiple files.
- 7.8 Why (non-const) global variables are evil: Learn the drawbacks of using non-constant global variables and best practices to avoid them.
- 7.9 Inline functions and variables: Explore inline functions and variables for potential performance optimizations.
- 7.10 Sharing global constants across multiple files (using inline variables): Learn how to share global constants efficiently using inline variables.
- 7.11 Static local variables: Understand static local variables and their persistent storage across function calls.
- 7.12 Scope, duration, and linkage summary: Review and consolidate your understanding of scope, duration, and linkage.
- 7.13 Using declarations and using directives: Learn to use
using
declarations and directives for namespace management. - 7.14 Unnamed and inline namespaces: Explore unnamed and inline namespaces for specific code organization needs.
- 7.x Chapter 7 summary and quiz: Review and test your knowledge of scope, duration, and linkage in C++.
Chapter 8: Control Flow
Control flow determines the order in which statements are executed. Chapter 8 covers essential control flow mechanisms in C++.
- 8.1 Control flow introduction: Get an overview of control flow concepts and their importance in program logic.
- 8.2 If statements and blocks: Master
if
statements and blocks for conditional execution based on boolean expressions. - 8.3 Common if statement problems: Learn about common mistakes when using
if
statements and how to avoid them. - 8.4 Constexpr if statements: Explore
constexpr if
statements for compile-time conditional code execution. - 8.5 Switch statement basics: Learn to use
switch
statements for efficient multi-way branching based on a variable’s value. - 8.6 Switch fallthrough and scoping: Understand switch fallthrough behavior and scoping within
switch
statements. - 8.7 Goto statements: Learn about
goto
statements (and why they should be used sparingly). - 8.8 Introduction to loops and while statements: Begin learning about loops with
while
statements for repetitive execution based on a condition. - 8.9 Do while statements: Explore
do-while
loops, which guarantee at least one execution of the loop body. - 8.10 For statements: Master
for
loops for structured iteration with initialization, condition, and increment/decrement. - 8.11 Break and continue: Learn to use
break
andcontinue
statements to control loop execution flow. - 8.12 Halts (exiting your program early): Understand how to terminate program execution prematurely when needed.
- 8.13 Introduction to random number generation: Begin exploring random number generation in C++.
- 8.14 Generating random numbers using Mersenne Twister: Learn to use the Mersenne Twister engine for high-quality random number generation.
- 8.15 Global random numbers (Random.h): Explore techniques for managing global random number generators.
- 8.x Chapter 8 summary and quiz: Review and reinforce your knowledge of control flow structures in C++.
Chapter 9: Error Detection and Handling
Effective error handling is crucial for robust programs. Chapter 9 introduces techniques for detecting and handling errors in C++.
- 9.1 Introduction to testing your code: Understand the importance of testing and basic testing strategies for C++ code.
- 9.2 Code coverage: Learn about code coverage and how it helps assess the thoroughness of your testing.
- 9.3 Common semantic errors in C++: Become aware of common semantic errors that are often harder to detect than syntax errors.
- 9.4 Detecting and handling errors: Explore various techniques for detecting and gracefully handling errors in your programs.
- 9.5 std::cin and handling invalid input: Learn to handle invalid input from
std::cin
to prevent program crashes. - 9.6 Assert and static_assert: Utilize
assert
andstatic_assert
for runtime and compile-time assertions to catch errors early. - 9.x Chapter 9 summary and quiz: Review and solidify your error detection and handling skills in C++.
Chapter 10: Type Conversion, Type Aliases, and Type Deduction
Chapter 10 delves into type conversion, type aliases for code readability, and type deduction for modern C++ programming.
- 10.1 Implicit type conversion: Understand implicit type conversions and potential pitfalls.
- 10.2 Floating-point and integral promotion: Learn about floating-point and integral promotion rules in C++.
- 10.3 Numeric conversions: Explore different types of numeric conversions and their behavior.
- 10.4 Narrowing conversions, list initialization, and constexpr initializers: Understand narrowing conversions and how list initialization helps prevent them.
- 10.5 Arithmetic conversions: Learn about arithmetic conversions that occur during operations with mixed data types.
- 10.6 Explicit type conversion (casting) and static_cast: Master explicit type casting using
static_cast
for controlled type conversions. - 10.7 Typedefs and type aliases: Use
typedef
and type aliases for creating more readable and maintainable code. - 10.8 Type deduction for objects using the auto keyword: Leverage
auto
keyword for automatic type deduction of objects, simplifying code. - 10.9 Type deduction for functions: Understand type deduction in function return types and parameters.
- 10.x Chapter 10 summary and quiz: Review and test your knowledge of type conversion, aliases, and deduction in C++.
Chapter 11: Function Overloading and Function Templates
Chapter 11 introduces function overloading for code flexibility and function templates for generic programming.
- 11.1 Introduction to function overloading: Learn about function overloading, allowing multiple functions with the same name but different parameters.
- 11.2 Function overload differentiation: Understand how the compiler differentiates between overloaded functions.
- 11.3 Function overload resolution and ambiguous matches: Explore function overload resolution and how to handle ambiguous overload situations.
- 11.4 Deleting functions: Learn to delete functions to prevent specific overloads from being used.
- 11.5 Default arguments: Use default arguments to make functions more flexible and easier to call with common parameter values.
- 11.6 Function templates: Discover function templates for writing generic functions that work with multiple data types.
- 11.7 Function template instantiation: Understand how function templates are instantiated by the compiler.
- 11.8 Function templates with multiple template types: Create function templates that work with multiple generic types.
- 11.9 Non-type template parameters: Explore non-type template parameters for passing constant values as template arguments.
- 11.10 Using function templates in multiple files: Learn how to organize and use function templates across multiple code files.
- 11.x Chapter 11 summary and quiz: Review and solidify your understanding of function overloading and templates in C++.
Chapter F: Constexpr functions (Optional Chapter)
Chapter F (Optional) delves into constexpr
functions, enabling compile-time function execution for performance benefits.
- F.1 Constexpr functions: Introduction to
constexpr
functions and their compile-time evaluation capabilities. - F.2 Constexpr functions (part 2): Further exploration of
constexpr
functions and their applications. - F.3 Constexpr functions (part 3) and consteval: Learn about
consteval
functions, which enforce compile-time evaluation. - F.4 Constexpr functions (part 4): Advanced topics and use cases for
constexpr
andconsteval
functions. - F.X Chapter F summary and quiz: Review and test your knowledge of
constexpr
functions.
Chapter 12: Compound Types: References and Pointers
Chapter 12 introduces compound types, focusing on references and pointers, which are fundamental for memory management and efficient data manipulation in C++.
- 12.1 Introduction to compound data types: Get an overview of compound data types built from fundamental types.
- 12.2 Value categories (lvalues and rvalues): Understand lvalues and rvalues, important concepts for references and move semantics.
- 12.3 Lvalue references: Learn about lvalue references, aliases to existing variables.
- 12.4 Lvalue references to const: Understand lvalue references to
const
for read-only aliases. - 12.5 Pass by lvalue reference: Learn to pass function arguments by lvalue reference for efficiency.
- 12.6 Pass by const lvalue reference: Use pass by
const
lvalue reference to avoid accidental modifications and improve efficiency. - 12.7 Introduction to pointers: Begin working with pointers, variables that store memory addresses.
- 12.8 Null pointers: Understand null pointers and how to check for invalid memory addresses.
- 12.9 Pointers and const: Explore the interaction between pointers and
const
for controlling data modification through pointers. - 12.10 Pass by address: Learn to pass arguments by address using pointers.
- 12.11 Pass by address (part 2): Further exploration of pass by address and its use cases.
- 12.12 Return by reference and return by address: Understand how to return references and pointers from functions.
- 12.13 In and out parameters: Learn to use references and pointers for in and out parameters in functions.
- 12.14 Type deduction with pointers, references, and const: Understand how
auto
type deduction works with pointers and references. - 12.15 std::optional: Explore
std::optional
for representing values that may or may not be present. - 12.x Chapter 12 summary and quiz: Review and solidify your understanding of references and pointers in C++.
Chapter 13: Compound Types: Enums and Structs
Chapter 13 continues with compound types, introducing enumerations (enums
) for named constants and structures (structs
) for grouping related data.
- 13.1 Introduction to program-defined (user-defined) types: Get an overview of user-defined types, including enums and structs.
- 13.2 Unscoped enumerations: Learn about unscoped enumerations for creating sets of named integer constants.
- 13.3 Unscoped enumerator integral conversions: Understand implicit conversions between unscoped enumerators and integers.
- 13.4 Converting an enumeration to and from a string: Learn techniques for converting enums to strings for output and vice versa for input.
- 13.5 Introduction to overloading the I/O operators: Begin learning about operator overloading, specifically for input/output operations with custom types.
- 13.6 Scoped enumerations (enum classes): Explore scoped enumerations (
enum classes
) for type-safe enumerations with no implicit conversions. - 13.7 Introduction to structs, members, and member selection: Learn about structs for grouping data members and how to access members using the dot operator.
- 13.8 Struct aggregate initialization: Understand aggregate initialization for structs.
- 13.9 Default member initialization: Learn to provide default values for struct members during declaration.
- 13.10 Passing and returning structs: Learn how to pass structs as function arguments and return structs from functions.
- 13.11 Struct miscellany: Explore additional features and considerations for structs.
- 13.12 Member selection with pointers and references: Learn to access struct members using pointers and references (arrow operator).
- 13.13 Class templates: Introduction to class templates for creating generic classes.
- 13.14 Class template argument deduction (CTAD) and deduction guides: Understand class template argument deduction and deduction guides for simplifying template instantiation.
- 13.15 Alias templates: Learn about alias templates for creating aliases for template instantiations.
- 13.x Chapter 13 summary and quiz: Review and test your knowledge of enums and structs in C++.
- 13.y Using a language reference: Guidance on using C++ language references for looking up syntax and features.
Chapter 14: Introduction to Classes
Chapter 14 marks the beginning of object-oriented programming (OOP) in C++, introducing classes as the foundation of OOP.
- 14.1 Introduction to object-oriented programming: Get an overview of OOP principles and its benefits.
- 14.2 Introduction to classes: Learn about classes as blueprints for creating objects and encapsulating data and behavior.
- 14.3 Member functions: Understand member functions (methods) within classes for defining object behavior.
- 14.4 Const class objects and const member functions: Explore
const
class objects andconst
member functions for ensuring data immutability. - 14.5 Public and private members and access specifiers: Learn about access specifiers (
public
,private
) for controlling member visibility and encapsulation. - 14.6 Access functions: Use access functions (getters and setters) to control access to private data members.
- 14.7 Member functions returning references to data members: Understand member functions that return references to data members and their implications.
- 14.8 The benefits of data hiding (encapsulation): Discover the advantages of data hiding and encapsulation in OOP.
- 14.9 Introduction to constructors: Learn about constructors, special member functions for object initialization.
- 14.10 Constructor member initializer lists: Use member initializer lists for efficient and proper constructor initialization.
- 14.11 Default constructors and default arguments: Understand default constructors and how default arguments can simplify constructor usage.
- 14.12 Delegating constructors: Learn about delegating constructors for code reuse and cleaner constructor implementations.
- 14.13 Temporary class objects: Understand temporary class objects and their lifetime.
- 14.14 Introduction to the copy constructor: Begin learning about copy constructors for creating copies of objects.
- 14.15 Class initialization and copy elision: Explore class initialization and copy elision optimizations.
- 14.16 Converting constructors and the explicit keyword: Learn about converting constructors and how
explicit
keyword prevents unintended conversions. - 14.17 Constexpr aggregates and classes: Explore
constexpr
aggregates and classes for compile-time object creation. - 14.x Chapter 14 summary and quiz: Review and solidify your understanding of classes and basic OOP concepts in C++.
Chapter 15: More on Classes
Chapter 15 expands on classes, covering advanced topics like the this
pointer, header file organization, nested types, destructors, static members, and friend functions.
- 15.1 The hidden “this” pointer and member function chaining: Understand the
this
pointer and how it enables member function chaining. - 15.2 Classes and header files: Learn best practices for organizing class declarations in header files and definitions in source files.
- 15.3 Nested types (member types): Explore nested types (classes, enums) defined within classes.
- 15.4 Introduction to destructors: Learn about destructors, special member functions for object cleanup when objects go out of scope.
- 15.5 Class templates with member functions: Create class templates with member functions for generic class behavior.
- 15.6 Static member variables: Understand static member variables shared by all objects of a class.
- 15.7 Static member functions: Learn about static member functions that operate on the class itself rather than specific objects.
- 15.8 Friend non-member functions: Use friend non-member functions to grant external functions access to private class members.
- 15.9 Friend classes and friend member functions: Explore friend classes and friend member functions for granting friendship between classes.
- 15.10 Ref qualifiers: Learn about ref qualifiers for differentiating member functions based on object value category.
- 15.x Chapter 15 summary and quiz: Review and test your advanced class concepts in C++.
Chapter 16: Dynamic arrays: std::vector
Chapter 16 introduces dynamic arrays using std::vector
, a powerful and flexible container from the C++ Standard Template Library (STL).
- 16.1 Introduction to containers and arrays: Get an overview of containers and arrays in C++.
- 16.2 Introduction to std::vector and list constructors: Begin working with
std::vector
and learn about its constructors. - 16.3 std::vector and the unsigned length and subscript problem: Understand potential issues with unsigned length and subscripting in
std::vector
. - 16.4 Passing std::vector: Learn best practices for passing
std::vector
objects to functions. - 16.5 Returning std::vector, and an introduction to move semantics: Understand how to return
std::vector
efficiently and get a first look at move semantics. - 16.6 Arrays and loops: Iterate through
std::vector
elements using loops. - 16.7 Arrays, loops, and sign challenge solutions: Practice array and loop manipulation with challenge solutions.
- 16.8 Range-based for loops (for-each): Use range-based for loops for simpler iteration over
std::vector
elements. - 16.9 Array indexing and length using enumerators: Combine enumerators with
std::vector
indexing and length management. - 16.10 std::vector resizing and capacity: Understand
std::vector
resizing and capacity management for performance optimization. - 16.11 std::vector and stack behavior: Explore how
std::vector
can be used to implement stack-like behavior. - 16.12 std::vector: Learn about
std::vector<bool>
and its space optimizations. - 16.x Chapter 16 summary and quiz: Review and solidify your understanding of dynamic arrays using
std::vector
.
Chapter 17: Fixed-size arrays: std::array and C-style arrays
Chapter 17 covers fixed-size arrays using std::array
(STL) and traditional C-style arrays.
- 17.1 Introduction to std::array: Begin working with
std::array
, a fixed-size array container from the STL. - 17.2 std::array length and indexing: Learn about
std::array
length and element access using indexing. - 17.3 Passing and returning std::array: Understand how to pass and return
std::array
objects efficiently. - 17.4 std::array of class types, and brace elision: Use
std::array
to store class objects and explore brace elision during initialization. - 17.5 Arrays of references via std::reference_wrapper: Learn to create arrays of references using
std::reference_wrapper
. - 17.6 std::array and enumerations: Combine
std::array
with enumerations for structured data representation. - 17.7 Introduction to C-style arrays: Learn about traditional C-style arrays and their syntax.
- 17.8 C-style array decay: Understand C-style array decay to pointers and its implications.
- 17.9 Pointer arithmetic and subscripting: Explore pointer arithmetic and its relationship to array subscripting.
- 17.10 C-style strings: Work with C-style strings (character arrays) and their limitations.
- 17.11 C-style string symbolic constants: Use symbolic constants for C-style string literals.
- 17.12 Multidimensional C-style Arrays: Learn about multidimensional C-style arrays.
- 17.13 Multidimensional std::array: Create and use multidimensional
std::array
objects. - 17.x Chapter 17 summary and quiz: Review and test your knowledge of fixed-size arrays using
std::array
and C-style arrays.
Chapter 18: Iterators and Algorithms (under construction)
Chapter 18 (under construction) introduces iterators and algorithms from the STL, powerful tools for data manipulation.
- 18.1 Sorting an array using selection sort: Implement selection sort algorithm for sorting arrays.
- 18.2 Introduction to iterators: Begin learning about iterators as generalized pointers for traversing containers.
- 18.3 Introduction to standard library algorithms: Get an overview of standard library algorithms for common data operations.
- 18.4 Timing your code: Learn techniques for measuring code execution time for performance analysis.
Chapter 19: Dynamic Allocation (under construction)
Chapter 19 (under construction) covers dynamic memory allocation using new
and delete
for managing memory at runtime.
- 19.1 Dynamic memory allocation with new and delete: Learn to allocate and deallocate memory dynamically using
new
anddelete
. - 19.2 Dynamically allocating arrays: Dynamically allocate arrays using
new
anddelete[]
. - 19.3 Destructors: Revisit destructors in the context of dynamic memory management.
- 19.4 Pointers to pointers and dynamic multidimensional arrays: Explore pointers to pointers for creating dynamic multidimensional arrays.
- 19.5 Void pointers: Learn about
void
pointers and their use for generic pointer types.
Chapter 20: Functions
Chapter 20 delves deeper into functions, covering function pointers, recursion, command-line arguments, and lambda functions.
- 20.1 Function Pointers: Learn about function pointers, variables that store addresses of functions, enabling function callbacks and dynamic function calls.
- 20.2 The stack and the heap: Understand the stack and heap memory areas and their roles in program execution.
- 20.3 Recursion: Explore recursion, functions that call themselves, for solving problems with self-similar subproblems.
- 20.4 Command line arguments: Learn how to access command-line arguments passed to your program.
- 20.5 Ellipsis (and why to avoid them): Understand ellipsis (
...
) for variable arguments (and why they are generally discouraged in modern C++). - 20.6 Introduction to lambdas (anonymous functions): Begin working with lambda functions (anonymous functions) for concise inline function definitions.
- 20.7 Lambda captures: Learn about lambda captures for accessing variables from the surrounding scope within lambdas.
- 20.x Chapter 20 summary and quiz: Review and test your knowledge of advanced function concepts in C++.
Chapter 21: Operator Overloading
Chapter 21 introduces operator overloading, allowing you to customize the behavior of operators for user-defined types.
- 21.1 Introduction to operator overloading: Learn about operator overloading and its benefits for creating more natural syntax for custom types.
- 21.2 Overloading the arithmetic operators using friend functions: Overload arithmetic operators (+, -, *, /) using friend functions.
- 21.3 Overloading operators using normal functions: Overload operators using non-member functions.
- 21.4 Overloading the I/O operators: Overload input (
>>
) and output (<<
) operators for custom types to enable seamless I/O. - 21.5 Overloading operators using member functions: Overload operators as member functions of classes.
- 21.6 Overloading unary operators +, -, and !: Overload unary operators (+, -, !) for custom types.
- 21.7 Overloading the comparison operators: Overload comparison operators (==, !=, <, >, <=, >=) for custom type comparisons.
- 21.8 Overloading the increment and decrement operators: Overload increment (++), and decrement (–) operators for custom types.
- 21.9 Overloading the subscript operator: Overload the subscript operator (
[]
) for custom container-like types. - 21.10 Overloading the parenthesis operator: Overload the parenthesis operator (
()
) to create function objects (functors). - 21.11 Overloading typecasts: Overload type cast operators to enable conversions between custom types and other types.
- 21.12 Overloading the assignment operator: Overload the assignment operator (
=
) for custom types, especially when managing dynamic memory. - 21.13 Shallow vs. deep copying: Understand the difference between shallow and deep copying and their relevance to assignment operator overloading.
- 21.14 Overloading operators and function templates: Combine operator overloading with function templates for generic operator behavior.
- 21.x Chapter 21 summary and quiz: Review and solidify your understanding of operator overloading in C++.
- 21.y Chapter 21 project: Apply operator overloading concepts in a practical project.
Chapter 22: Move Semantics and Smart Pointers
Chapter 22 introduces move semantics and smart pointers for efficient resource management and preventing memory leaks.
- 22.1 Introduction to smart pointers and move semantics: Get an overview of smart pointers and move semantics for improved resource management.
- 22.2 R-value references: Learn about r-value references, essential for move semantics.
- 22.3 Move constructors and move assignment: Implement move constructors and move assignment operators for efficient resource transfer.
- 22.4 std::move: Use
std::move
to explicitly trigger move semantics. - 22.5 std::unique_ptr: Learn to use
std::unique_ptr
for exclusive ownership of dynamically allocated objects. - 22.6 std::shared_ptr: Explore
std::shared_ptr
for shared ownership of dynamically allocated objects with automatic deallocation. - 22.7 Circular dependency issues with std::shared_ptr, and std::weak_ptr: Understand circular dependency problems with
std::shared_ptr
and how to resolve them usingstd::weak_ptr
. - 22.x Chapter 22 summary and quiz: Review and test your knowledge of move semantics and smart pointers.
Chapter 23: Object Relationships
Chapter 23 explores different types of relationships between objects in OOP: composition, aggregation, association, and dependencies.
- 23.1 Object relationships: Get an overview of different types of object relationships in OOP design.
- 23.2 Composition: Understand composition (“has-a” relationship where the contained object’s lifetime is dependent on the container).
- 23.3 Aggregation: Learn about aggregation (“has-a” relationship where the contained object can exist independently of the container).
- 23.4 Association: Explore association (“uses-a” relationship, a general relationship between objects).
- 23.5 Dependencies: Understand dependencies (“uses-a” relationship, but often more temporary and less direct than association).
- 23.6 Container classes: Design container classes to manage collections of objects.
- 23.7 std::initializer_list: Use
std::initializer_list
for convenient initialization of container classes. - 23.x Chapter 23 summary and quiz: Review and solidify your understanding of object relationships in OOP.
Chapter 24: Inheritance
Chapter 24 introduces inheritance, a core OOP principle for code reuse and creating class hierarchies.
- 24.1 Introduction to inheritance: Get an overview of inheritance and its benefits for code organization and extensibility.
- 24.2 Basic inheritance in C++: Implement basic inheritance in C++ to create derived classes from base classes.
- 24.3 Order of construction of derived classes: Understand the order of constructor calls during derived class object creation.
- 24.4 Constructors and initialization of derived classes: Learn how to properly initialize base class members from derived class constructors.
- 24.5 Inheritance and access specifiers: Explore the impact of access specifiers (
public
,protected
,private
) on inherited members. - 24.6 Adding new functionality to a derived class: Extend derived classes with new members and functions.
- 24.7 Calling inherited functions and overriding behavior: Call base class functions from derived classes and override base class behavior in derived classes.
- 24.8 Hiding inherited functionality: Learn how to hide (shadow) inherited members in derived classes.
- 24.9 Multiple inheritance: Explore multiple inheritance (inheriting from multiple base classes) and its complexities.
- 24.x Chapter 24 summary and quiz: Review and test your knowledge of inheritance in C++.
Chapter 25: Virtual Functions
Chapter 25 covers virtual functions and polymorphism, enabling dynamic dispatch and runtime polymorphism in OOP.
- 25.1 Pointers and references to the base class of derived objects: Understand how pointers and references to base classes can point to derived class objects.
- 25.2 Virtual functions and polymorphism: Learn about virtual functions and how they enable polymorphism (runtime selection of the correct function based on object type).
- 25.3 The override and final specifiers, and covariant return types: Use
override
andfinal
specifiers for virtual function control and explore covariant return types. - 25.4 Virtual destructors, virtual assignment, and overriding virtualization: Understand virtual destructors for proper object cleanup in inheritance hierarchies and considerations for virtual assignment.
- 25.5 Early binding and late binding: Differentiate between early binding (compile-time) and late binding (runtime) in function calls.
- 25.6 The virtual table: Get a glimpse into the virtual table (vtable) mechanism that implements virtual functions.
- 25.7 Pure virtual functions, abstract base classes, and interface classes: Learn about pure virtual functions, abstract base classes, and interface classes for defining abstract interfaces.
- 25.8 Virtual base classes: Explore virtual base classes for resolving diamond inheritance problems.
- 25.9 Object slicing: Understand object slicing and its consequences when working with inheritance and object copying.
- 25.10 Dynamic casting: Use dynamic casting for safe downcasting in inheritance hierarchies.
- 25.11 Printing inherited classes using operator<<: Learn how to overload the output operator for inherited classes to handle polymorphism correctly.
- 25.x Chapter 25 summary and quiz: Review and solidify your understanding of virtual functions and polymorphism in C++.
Chapter 26: Templates and Classes
Chapter 26 combines templates with classes, exploring template classes, non-type template parameters, and template specialization.
- 26.1 Template classes: Learn to create template classes for generic class implementations.
- 26.2 Template non-type parameters: Use non-type template parameters in class templates.
- 26.3 Function template specialization: Specialize function templates for specific template arguments.
- 26.4 Class template specialization: Specialize entire class templates for specific template arguments.
- 26.5 Partial template specialization: Partially specialize class templates for a subset of template arguments.
- 26.6 Partial template specialization for pointers: Explore partial specialization specifically for pointer types.
- 26.x Chapter 26 summary and quiz: Review and test your knowledge of templates and classes combined.
Chapter 27: Exceptions
Chapter 27 covers exception handling in C++, a robust mechanism for dealing with runtime errors gracefully.
- 27.1 The need for exceptions: Understand the motivation for exception handling and its advantages over traditional error codes.
- 27.2 Basic exception handling: Learn basic exception handling syntax using
try
,catch
, andthrow
. - 27.3 Exceptions, functions, and stack unwinding: Understand stack unwinding during exception propagation through function call stacks.
- 27.4 Uncaught exceptions and catch-all handlers: Learn about uncaught exceptions and how to implement catch-all handlers.
- 27.5 Exceptions, classes, and inheritance: Use classes and inheritance for creating custom exception types.
- 27.6 Rethrowing exceptions: Rethrow exceptions from catch blocks to allow further handling up the call stack.
- 27.7 Function try blocks: Use function try blocks to handle exceptions thrown during constructor initialization.
- 27.8 Exception dangers and downsides: Be aware of potential downsides and performance considerations related to exception handling.
- 27.9 Exception specifications and noexcept: Explore exception specifications (deprecated in C++17, removed in C++20) and
noexcept
specifier. - 27.10 std::move_if_noexcept: Use
std::move_if_noexcept
for conditional move operations based on exception safety. - 27.x Chapter 27 summary and quiz: Review and solidify your exception handling skills in C++.
Chapter 28: Input and Output (I/O)
Chapter 28 provides a comprehensive overview of C++ input and output (I/O) streams, including file I/O.
- 28.1 Input and output (I/O) streams: Get an overview of I/O streams and the C++ I/O stream library.
- 28.2 Input with istream: Learn to use
istream
classes for various input operations. - 28.3 Output with ostream and ios: Explore
ostream
andios
classes for output formatting and manipulation. - 28.4 Stream classes for strings: Use stream classes for in-memory string I/O operations.
- 28.5 Stream states and input validation: Understand stream states and how to perform input validation to handle errors.
- 28.6 Basic file I/O: Learn to perform basic file input and output operations.
- 28.7 Random file I/O: Explore random access file I/O for reading and writing data at arbitrary positions in files.
Appendix A: Miscellaneous Subjects
Appendix A covers miscellaneous subjects related to C++ development.
- A.1 Static and dynamic libraries: Understand the difference between static and dynamic libraries and their use in C++ projects.
- A.2 Using libraries with Visual Studio: Learn how to use libraries with the Visual Studio IDE.
- A.3 Using libraries with Code::Blocks: Learn how to use libraries with the Code::Blocks IDE.
- A.4 C++ FAQ: Find answers to frequently asked questions about C++.
Appendix B: C++ Updates
Appendix B provides introductions to recent C++ standard updates.
- B.1 Introduction to C++11: Get an overview of new features introduced in C++11.
- B.2 Introduction to C++14: Explore new features in C++14.
- B.3 Introduction to C++17: Discover new features in C++17.
- B.4 Introduction to C++20: Learn about new features in C++20.
- B.5 Introduction to C++23: Get a glimpse of upcoming features in C++23.
Appendix C: The End
Appendix C marks the conclusion of the LearnCpp.com tutorial series (for now!).
- C.1 The end?: A concluding message and potential future directions.
Appendix D: Deprecated Articles (will be removed soon)
Appendix D lists deprecated articles that are planned for removal. These cover older content on the Standard Library and std::string
.
LearnCpp.com provides a truly comprehensive and free pathway to Learn C++ Programming Language. By meticulously following this structured curriculum, you can gain a strong foundation and advance your skills to become a proficient C++ developer. Start your learning journey today and unlock the power of C++!