What is the meaning of “wild pointer” in C?

前端 未结 11 1661
终归单人心
终归单人心 2020-11-30 04:14

Can anybody tell me, the meaning of wild pointer in C, how to obtain it and is this available in C++?

11条回答
  •  长情又很酷
    2020-11-30 04:41

    To get a wild (aka dangling) pointer you:

    • Create an object
    • Create a pointer to that object
    • Delete the object
    • Forget to set the pointer to null

    The pointer is now classed as "wild" as it's pointing to an arbitrary piece of memory and using it in this state could cause problems with your program.

提交回复
热议问题