"No viable overloaded '=' "

Im having trouble trying to remove this whole array member But everytime I try to remove it and move the others I get the error. Lets just Say im trying to remove this line here. How would I do it? This is C++ btw.
Lassen California 5720 24 11624

[/*void display_removal(const Covid arr[], int& n, string name)
{
bool is_found = false;
for (int i = 0; i < n; i++)
{
if (is_found)
arr[i-1] = arr[i];
else if (arr[i].city == name)
is_found = true;
}


}
I would basically put in that city (Lassen) and then it would remove the whole line. But "arr[i-1] = arr[i]; is where the error appears
Last edited on
> void display_removal(const Covid arr[], int& n, string name)
Well here you promised that you weren't going to change the array.

A name like 'display' does suggest it's only going to be looking at the data, so you can see it on screen somewhere.

But that seems to be a bad name, because the function contains no output functionality at all.


Thank you so much for the help. I see how display is misleading, my bad but "const" didn't even cross my mind.
What if there are more than one entry with same name?

What if there are no entries with that name? How does the caller know whether any were "removed"?
Topic archived. No new replies allowed.