Delete element from C++ array

前端 未结 11 883
逝去的感伤
逝去的感伤 2020-12-11 14:26

Please tell me how to delete an element from a C++ array.

My teacher is setting its value to 0, is that correct?

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-11 14:53

    You can't really "delete" an element from a C++ array.

    However, if the array consists of pointers, you can delete the object that a specific element points to.

    In your teacher's case, it will be important to make note of whether the objects of the array are dynamically allocated (using the new operator in C++) or not. He may simply be setting his values to 0 as an indicator that the value is no longer valid.

    Without actual source code, this is as much as I can help you with.

提交回复
热议问题