Skip to content

Tag Archives: C++-new and delete

Prerequisite: Array BasicsIn C/C++, multidimensional arrays in simple words as an array of arrays. Data in multidimensional arrays are stored in tabular form (in row… Read More
A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant,… Read More
In this article, if memory allocation using new is failed in C++ then how it should be handled? When an object of a class is… Read More
As we know that new is used to create memory dynamically and it is the programmer’s responsibility to delete the memory location explicitly and it… Read More
We use new and delete operators in C++ to dynamically allocate memory whereas malloc() and free() functions are also used for the same purpose in… Read More
The below section deals about overload resolution as it helps in the fundamentals of overloading and overriding. Predict the output: #include <iostream> using namespace std;… Read More
There are two parts of memory in which an object can be stored: stack – Memory from the stack is used by all the members… Read More
Is it fine to call delete twice for a pointer? #include<iostream> using namespace std;    int main() {     int *ptr = new int;     delete ptr;… Read More
What happens when delete is used for a NULL pointer? int *ptr = NULL; delete ptr;  (A) Compiler Error (B) Run-time Crash (C) No Effect… Read More
Predict the output? #include <iostream> using namespace std;    class Test  {   int x;   Test() { x = 5;} };    int main() {    Test… Read More
Which of the following is true about new when compared with malloc. 1) new is an operator, malloc is a function 2) new calls constructor,… Read More
How to create a dynamic array of pointers (to integers) of size 10 using new in C++? Hint: We can create a non-dynamic array using… Read More

Start Your Coding Journey Now!