It is valid code or not | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

It is valid code or not

is it valid code or not T *p=0; delete p;

24th Jul 2017, 11:08 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
5 Answers
0
delete null pointer is safe. Nothing will happen and nothing illegal. But here you shouldn't delete anything , because you didn't allocate the memory with new operator
24th Jul 2017, 11:13 AM
soman
+ 1
its run but not give any output
24th Jul 2017, 11:14 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 1
thanks @sonam
24th Jul 2017, 11:18 AM
Mayur Chaudhari
Mayur Chaudhari - avatar
+ 1
it's valid but not official
25th Jul 2017, 6:50 PM
gehad
gehad - avatar
0
try it and then check it
24th Jul 2017, 11:13 AM
ch.chitti srilakshmi
ch.chitti srilakshmi - avatar