search

Home  >  Q&A  >  body text

c++ - const指针需要释放吗?

它是在堆里还是在栈里?

ringa_leeringa_lee2804 days ago582

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 13:56:51

    const is on the stack, and the stack space is automatically released, so you don’t have to worry about it;
    Heap space is generally applied for by new and malloc, and you need to release it.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 13:56:51

    The memory pointed to by the pointer is allocated on the stack and does not need to be released manually. The memory allocated on the heap needs to be released manually.
    I suggest spending some time reading some related books.

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 13:56:51

    Go here to test? C++ online compilation and execution

    reply
    0
  • Cancelreply