Delete element from C++ array

前端 未结 11 886
逝去的感伤
逝去的感伤 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条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-11 15:03

    If you're talking about a normal array, e.g.

    int array[100];
    

    then you can't "delete" an element, since the array always has 100 elements (in this example).

    So it depends on the interpretation your program makes of the array values. If your teacher is consistently using a value of 0 to mean non-existent element, everything will work and so that's as correct as any other approach.

提交回复
热议问题