Answer the following questions true (T) or false (F)
1. Dangling pointers present no problem in C++
2. Dynamic variables or dynamically allocated variables in C++ are created and destroyed according to the program’s needs.
1. False
Explanation: A dangling pointer occurs when several pointers point to the same chunk of allocated freestore memory. If one of the pointers has had the delete
pointer applied to it, releasing the freestore memory, the other pointers are said to be dangling. Because the pointer that had delete applied to it most of the time isn’t
changed by the delete operation (not guaranteed by any means), a deleted pointer is frequently called a ‘dangling pointer.’
2. True
Explanation: Dynamic variables are unaffected by function calls or function return. This is not true of local pointer variables that may point to dynamic variables. Consequently, in a poorly written program, a local pointer can go out of scope and the dynamic variable to which the pointer points may be lost.
You might also like to view...
Suppose the only mutual exclusion primitive provided to user-level threads is a command that disables interrupts for the next 32 instructions, then reenables interrupts. Explain the benefits and drawbacks of this approach.
What will be an ideal response?
Write access expressions for all the elements in row 1 of t.
Consider a two-by-three integer array t.
A(n) ____ is someone who breaks into computer systems, launches Internet worms and viruses, or perpetrates other dubious computer-related vandalism.
A. encryption B. PGP C. utilitarian D. hacker
A teacher who shares a poem with his class and leads the class to believe the poem is his original work has engaged in ____.
A. bad manners B. plagiarism C. trademark theft D. patent infringement