what does new do in C++? related to dynamic memory allocation please help me?
Often, we do not know the size of an array at compile time. Allocate memory dynamically in a program using new.But in C++, memory needs to be reclaimed using delete. Frequently used technique in class members to allocate variable sized data structures – arrays of unknown size, e.g. a stack class with user-specificed number of elements – allocate space on a per request basis, e.g. allocate a buffer/memory to receive messages (http requests) from a construct..if you are still in confusion between static and dynamic memory allocation just lokk over this.. -Dynamically allocated memory is kept on the memory heap (also as the free store) -Dynamically allocated memory can't have a "name" it must be referred to -Declarations are used to statically allocate memory, the new operator is used to dynamically allocate memory
Join our real-time social learning platform and learn together with your friends!