

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to memory allocation in c++ through pointers and dynamic allocation functions such as malloc, calloc, realloc, new, and delete. Topics covered include memory allocation for classes and objects, pointer to a class, and the process of allocating, populating, and deleting memory. Examples are given to illustrate the usage of these functions.
Typology: Slides
1 / 33
This page cannot be seen from the preview
Don't miss anything!


























Today’s Lecture How memory allocation is done in C++ How is it different from C style Advantages of memory allocation in C++ Uses of memory allocation
Pointers to a class
malloc ( ) ; calloc ( ) ; realloc ( ) ;
malloc ( 10 * ( sizeof ( int ) ) ) ;
new
new int ;
new char ; new double ; Example
delete
int * iptr ; iptr = new int [ 10 ] ; Example
Example
Example
dptr = new Date ;