Pointers and References in C++: Allocating Memory with New & Delete Operators

C++ 20    |    Intermediate
  • 13 Videos | 1h 25m 18s
  • Includes Assessment
  • Earns a Badge
C++, like C, has powerful support for memory allocation and deallocation. In the world of C, these operations are performed using malloc() and free(), which are not to be used in the C++ world. In classic C++, memory allocation and deallocation are performed using the new and delete operators. You will begin this course by understanding the new and delete keywords, and note how these lead to the invocation of the underlying constructors and destructors on whatever objects are being worked with. In contrast, the C versions, that is, malloc() and free(), do not invoke constructors or destructors. You will then move on to the use of array new and array delete, which is how the new and delete followed by square brackets are referred to. Finally, you will look at the differences between const pointers and pointers to consts.

WHAT YOU WILL LEARN

  • discover the key concepts covered in this course
    explore pointers and stack and free store memory
    contrast malloc() and new
    use the new keyword to allocate memory on the heap
    use the new and delete keywords on pointers
    allocate memory for strings and vectors
    allocate memory for arrays using array new and delete
  • invoke constructors and destructors on arrays
    contrast const pointers and pointers to consts
    create constant variables and pointers on those variables
    create constant pointers on constant and non-constant variables
    create constant pointers and constant pointers to constants
    summarize the key concepts covered in this course

IN THIS COURSE

  • Playable
    1. 
    Course Overview
    2m 8s
    UP NEXT
  • Playable
    2. 
    Understanding the Use of Pointers
    6m 2s
  • Locked
    3. 
    Allocating Memory in C++
    7m 29s
  • Locked
    4. 
    Allocating Memory Using the new Keyword
    6m 49s
  • Locked
    5. 
    Understanding Finer Points of New and Delete
    7m 49s
  • Locked
    6. 
    Creating Strings and Vectors on the Heap
    6m 37s
  • Locked
    7. 
    Allocating Memory for Arrays on the Heap
    5m 20s
  • Locked
    8. 
    Exploring Finer Points of Array New and Delete
    7m 53s
  • Locked
    9. 
    Const Pointers versus Pointers to Consts
    7m 46s
  • Locked
    10. 
    Using Constant Variables and Pointers
    8m 34s
  • Locked
    11. 
    Creating Pointers to Constants
    8m 6s
  • Locked
    12. 
    Creating Constant Pointers
    7m 30s
  • Locked
    13. 
    Course Summary
    3m 15s

EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE

Skillsoft is providing you the opportunity to earn a digital badge upon successful completion of this course, which can be shared on any social network or business platform

Digital badges are yours to keep, forever.