Pointers and References in C++: Allocating Memory with New & Delete Operators
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.