Tuesday, September 6, 2016

Dynamic memory allocator: new in C++

In c++ we will use new operator to allocate memory dynamically . In this post we will know how this process happens and what are the steps involved while using new. Basic syntax for new is
new [placemenet-params] typename;
This expression will allocate the memory available from the free store and returns the pointer to the object of type 'typename'. And in case of class, struct types it will allocate memory and intialise the object then retun the pointer to the object 'typename'.