What is a dangling pointer?

Answer Posted / achal ubbott

Here is an example of dangling pointer.

char* p = new char;// allocate a byte from heap section.
delete p ; // deallocation.

*p = 44 ; // using a dangling pointer.

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Where are setjmp and longjmp used in c++?

608


What is fixed in c++?

577


Can a constructor return a value?

567


What are the benefits of oop in c++?

578


What does new do in c++?

627






How the keyword struct is different from the keyword class in c++?

576


How is computer programming useful in real life?

585


Explain the differences between list x; & list x();.

596


Difference between Abstraction and encapsulation in C++?

568


What are friend classes? What are advantages of using friend classes?

592


When do we use copy constructors?

587


Define whitespace in C++.

742


What is the use of 'this' pointer?

761


What is pure virtual function?

617


Why is null pointer used?

671