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

Differentiate between the message and method in c++?

610


Evaluate as true or false: !(1 &&0 || !1) a) True b) False c) Invalid statement

636


What is a c++ vector?

593


Can the operator == be overloaded for comparing two arrays consisting of characters by using string comparison?

566


How can you quickly find the number of elements stored in a static array?

638






Difference between a copy constructor and an assignment operator.

573


Differentiate between the manipulator and setf( ) function?

594


What is oops in c++?

589


Which one is better- macro or function?

656


Discuss the effects occur, after an exception thrown by a member function is unspecified by an exception specification?

638


How did c++ get its name?

574


Is ca high or low level language?

586


What is friend class in c++ with example?

500


What are the two types of comments, and how do they differ?

574


What is the cout in c++?

554