Difference between delete and delete[]?

Answer Posted / sunita shukla

Delete p deallocate memory pointed to by p and delete []p deallocate array. But delete p will delete only p[0]. Other array's Size-1 entries will not be deleted and this memory will leak.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why cout is used in c++?

566


What is difference between malloc()/free() and new/delete?

649


How can virtual functions in c++ be implemented?

612


Why c++ is created?

577


Write a program to show polymorphism in C++?

635






What is the purpose of ios::basefield in the following statement?

790


Write a function that swaps the values of two integers, using int* as the argument type?

609


what is a reference variable in C++?

669


How does code-bloating occur in c++?

753


What is code reusability in c++?

672


How do I tokenize a string in c++?

610


Can comments be longer than one line?

625


How do you differentiate between overloading the prefix and postfix increments?

593


What is the difference between an enumeration and a set of pre-processor # defines?

837


List the merits and demerits of declaring a nested class in C++?

610