answersLogoWhite

0

Definition of dangling pointer object

Updated: 8/16/2019
User Avatar

Wiki User

9y ago

Best Answer

A dangling pointer occurs when objects have been deallocated or deleted from the system. They 'dangle' due to the pointer's values still remaining leaving a location to the non-existent object in the memory.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Definition of dangling pointer object
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is dangling pointer reference in c plus plus?

A dangling pointer (we also use the terms stray pointer and wild pointer) is created whenever we call delete on a pointer and then try to use the pointer without reassigning it.We can also create dangling pointers inadvertently by calling a rogue function that returns a pointer to an object that is local to the function we are calling. The object will fall from scope when the function returns so the pointer is left dangling.Note that there is no such thing as a dangling pointer reference. Pointers and references are not the same. A reference is merely an alias to an object -- it consumes no memory beyond the object it refers to. Whereas a pointer is a variable that may contain the address of an object, but it requires additional memory to do so (4 bytes on 32-bit architecture). Pointers may be NULL, references can never be NULL. Pointers to valid objects require indirection, references do not. References are the preferred method of accessing an object's members, not least because they are easier to work with.


What is Dazzling Pointer in c plus plus?

The pointer that points to a block of memory that does not exist is called a dazzling pointer or wild pointer


Why you can not use this pointer in static functions?

Because this points to the current object, but static methods don't have a current object (actually this is definition of the static methods).


What is diffrent between object pointer and this pointer?

'this' is an object-pointer: it points to the current object (usable only in non-static methods).


What dire consequences could result from dereferencing a dangling pointer?

This could lead to a memory leak


When you let your pointer linger over an object the pointer is?

The pointer is non-NULL.


What does dangling mean?

Dangling refers to a situation where a pointer in a computer program points to a memory location that has been deallocated or is no longer valid. This can lead to unpredictable behavior and crashes in a program. Dangling pointers are a common source of bugs in C and C++ programs.


Why pointer is not an object?

A pointer in itself is not an object, because it is not an instance of a class. Of course you can define a class which has only one member, which is a pointer. class Pointer { public void *ptr; }; Pointer p, q, r;


Dangling reference in java?

I think you're referring to the C/C++ concept of "dangling pointers." This is when you allocate some memory to a pointer, then deallocate that memory, but don't change the pointer. This causes any attempted use of the pointer to return an unused memory address. There is no such concept in Java, since the programmer has little to no control over how memory is allocated or freed. The closest thing I can think of is if you're using a class such as a Reader, in which you can close the object (Reader.close()) and then still have a reference to it. But in this case (and other similar cases) attempting to use the Reader further will result in an IOException being thrown.


When does this pointer get created?

When we call non static method with respect to class object then this pointer is created which keep the reference of that object.


What is a dangling pointer in C and C plus plus?

A dangling pointer is one that points to a memory location but the memory itself has been freed or released back to the system. The memory may still contain valid information, but the system can overwrite the data at any time so any attempt to access that memory via the dangling pointer could prove disastrous. As soon as memory is released, the pointer is invalid -- because the memory it points to is potentially invalid. To prevent this, always nullify pointers (set them to point at memory address zero) when they are no longer required, immediately after releasing the memory they point to. There are occasion when this is not necessary, such as when releasing a member pointer in a class destructor, but if a pointer is re-used, it must be initialised before being accessed again.


Where string is stored on Heap or Stack in java?

A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.