Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Coursera

Practical Guide to Mastering C++ Smart Pointers - Part 01

Packt via Coursera

Overview

Google, IBM & Meta Certificates — All 10,000+ Courses at 40% Off
One annual plan covers every course and certificate on Coursera. 40% off for a limited time.
Get Full Access
This course features Coursera Coach! A smarter way to learn with interactive, real-time conversations that help you test your knowledge, challenge assumptions, and deepen your understanding as you progress through the course. Master the essentials of C++ smart pointers and dynamic memory management in this comprehensive course. Starting from the basics of C and C++ memory allocation, you will progressively learn how smart pointers like std::unique_ptr enhance memory safety and improve resource management in modern C++ code. As you advance, you’ll explore crucial concepts such as custom deleters, the PIMPL idiom, and using smart pointers within containers. You will also gain hands-on experience with practical examples, including game implementations and object pools, ensuring that you can apply what you learn in real-world projects. The course is structured into digestible sections, beginning with foundational memory management techniques and transitioning into smart pointer usage in C++. You'll explore different types of smart pointers, delve into best practices, and understand the implications of replacing raw pointers. The course also includes advanced topics that enable efficient memory management, improving your coding practices and software design. This course is ideal for intermediate programmers who are familiar with C++ basics and want to take their skills to the next level. It will benefit those interested in safe, efficient memory management in C++, especially for those working on complex systems and software applications. A strong understanding of basic C++ concepts and dynamic memory allocation is required, while the course will gradually build up your knowledge of smart pointers. By the end of the course, you will be able to confidently use smart pointers to manage dynamic memory in C++ effectively, avoid common pitfalls like memory leaks and dangling pointers, implement custom deleters, and optimize resource management in real-world applications.

Syllabus

  • Introduction
    • In this module, we will introduce the foundational concepts of smart pointers in C++. We will lay the groundwork for understanding the necessity of smart pointers and how they contribute to memory safety and resource management in C++ programming.
  • C Allocation Routines
    • In this module, we will explore dynamic memory allocation techniques in C. From malloc() and calloc() to realloc(), you'll learn the basics of handling memory in C before diving deeper into C++ memory management.
  • C++ Allocation Routines
    • In this module, we will discuss memory allocation in C++ using the new and new[] operators. You will learn to allocate memory, manage arrays, and handle memory allocation failures effectively, setting the stage for smart pointer usage.
  • Smart Pointers
    • In this module, we will introduce the concept of smart pointers in C++, explaining their significance and how they overcome common pitfalls associated with raw pointers, offering safer and more efficient memory management.
  • std::unique_ptr
    • In this module, we will dive into std::unique_ptr, showcasing its usage in managing dynamic memory. You will learn how to safely return and pass unique_ptrs, which helps ensure proper memory management and ownership semantics.
  • Replacing Raw Pointers
    • In this module, we will focus on replacing raw pointers with smart pointers to eliminate common memory management errors. We will discuss strategies for preventing uninitialized pointers, dangling references, and the importance of exception safety.
  • Deleters
    • In this module, we will introduce custom deleters within smart pointers, providing more flexibility and control over memory management. We’ll cover how to define and use custom deleters to handle various memory management scenarios effectively.
  • Make Functions
    • In this module, we will focus on std::make_unique and its role in simplifying memory management. You’ll learn how to use it to manage dynamic arrays safely and explore advanced techniques for efficient memory handling.
  • Pointer to IMPLementation
    • In this module, we will introduce the PIMPL (Pointer to IMPLementation) idiom, which is a valuable technique for hiding implementation details and managing memory more effectively in C++.
  • Project
    • In this module, we will walk through a project that implements key concepts of smart pointers in C++. You’ll develop a game and an object pool, applying everything you’ve learned about memory management using smart pointers.
  • Advanced Concepts
    • In this module, we will cover advanced C++ concepts, including constructor behavior, observer patterns, and operator overloading. You’ll also learn about constexpr unique_ptr for compile-time memory management.

Taught by

Packt - Course Instructors

Reviews

Start your review of Practical Guide to Mastering C++ Smart Pointers - Part 01

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.