Please tell me how to delete an element from a C++ array.
My teacher is setting its value to 0, is that correct?
it's an old topic but I'm gonna put this answer here for anyone who's recently seen this question!
deleting an element from the array is a heavy operation you can easily keep track of your elements with an index. anyway, you can call this function whenever you want to delete the first x element of a vector.
vector remove_frist_x_items(const vector& arr, int x)
{
return vector(arr.begin() + x, arr.end());
}
// Delete the first element from the array
auto new_array = remove_frist_x_items(the_old_one, 1);