wild pointer(野指针)和dangling pointer(悬空指针)
A dangling pointer is a pointer that used to point to a valid address but now
no longer does. This is usually due to that memory location being freed up and
no longer available. There is nothing wrong with having a dangling pointer
unless you try to access the memory location pointed at by that pointer.
It is always best practice not to have or leave dangling pointers.
A wild pointer is a pointer that has not been correctly initialized and
therefore points to some random piece of memory.
It is a serious error to have wild pointers.
野指针和悬空指针是编程中常见的错误类型。悬空指针是指曾经指向有效内存地址但现在不再可用的指针,尝试访问可能导致未定义行为。而野指针则是未正确初始化,可能指向内存的任意位置,同样带来不确定风险。最佳实践是避免留下这两种类型的指针,确保指针管理的正确性。
1003

被折叠的 条评论
为什么被折叠?



