What is ** in C++?

后端 未结 11 1261
野性不改
野性不改 2020-12-04 14:24

I\'ve seen some code, as well as some errors generated from my compiler that have a \'**\' token before the variable (eg **variablename unreferenced-- or someth

11条回答
  •  [愿得一人]
    2020-12-04 14:59

    One common use is that it allows a function to set the pointer to null.
    So free(pointer) frees up the memory allocated to pointer but leaves the pointer dangerously pointing at the free memory.
    Instead declare a my_free(**pointer) and call my_free(&pointer) so my_free() can set the pointer to null after freeing it.

提交回复
热议问题