Do i require checking for null before delete p?, C/C++ Programming

No. it's not required

The C++ language guarantees that delete p will do nothing if p is equivalent to NULL. As you might get the test backwards, and as most testing methodologies force you for performs test explicitly every branch point, you should not put in the redundant if test.

Wrong:                    

if (p != NULL)

delete p; Right: delete p;

 

Posted Date: 3/19/2013 8:40:07 AM | Location : United States







Related Discussions:- Do i require checking for null before delete p?, Assignment Help, Ask Question on Do i require checking for null before delete p?, Get Answer, Expert's Help, Do i require checking for null before delete p? Discussions

Write discussion on Do i require checking for null before delete p?
Your posts are moderated
Related Questions
Aim: To implement program to calculate area of cube using inline function. Code: inline void area_cube(float side) {             float area;             are


WAP TO PRINT ANY NAME ON SCREEN 10 TIMES void main () { int a=1; clrscr(); do { printf ("expertsmind\n"); a++; } while (a getch (); }

A:  it is containing and hiding Information regarding an object, like internal data structures and code. It isolates the internal complication of an object's operation from the res

Friend for Overloading Operators Sometimes friend functions cannot be avoided. For example with the operator overloading. Consider the following class that have data members to

Develop Online Slot Video Game for Facebook Prepare an online slot video game for a Facebook promotion in order to draw new visits and Increase the number of "likes" of the Face

The break statement The break statement, which was already covered in the switch.. case, can also be used in the loops. When a loop statement is encountered in the loops the co

What are all of the implicit member functions of the class? Or what are all of the functions that compiler implements for us if we don't describe one? A: 1.      copy ctor

Mixed Mode Expressions and Implicit type Conversions A mixed mode expression is one in which the operands are not of the similar type. In this case, the operands are converted

What is abstraction? - Simplified view of an object in user's language is termed as abstraction. - It's the simplest, well-defined interface to an object in OO and C++ which