Memory Management: new and delete in C++
Memory Management: new and delete in C++ Arrays can be used to store multiple homogenous data but there are serious drawbacks of using arrays. You should allocate the memory of an array when you declare it but most of the time, the exact memory needed cannot be determined until runtime. The best thing to do in this situation is to declare an array with maximum possible memory required (declare array with maximum possible size expected). The downside to this is unused memory is wasted and cannot be used by any other programs. To avoid wastage of memory, you can dynamically allocate memory required during runtime using new and delete operator in C++. Example 1: C++ Memory Management C++ Program to store GPA of n number of students and display it where n is the number of students entered by user. #include <iostream> #include <cstring> using namespace std ; int ma...