If you have an array of structs, initialize all the structs in the array to some value you know to be non-valid. You can put a constructor in the struct:
struct example{
int x;
int y;
int z;
example():x(-1),y(-1),z(-1){}
// for output using cout
friend ostream& operator <<(ostream& o, example e)
{
o<<e.x<<endl<<e.y<<endl<<e.z<<endl;
return o;
}
};
for the output you can set it to only output when x != -1 y != -1 etc
To remove them from the array
[1][2][3][4][5][6][7]
say you want to get rid of 4
shift 5 6 and 7 left so the new result will look like
1 2 3 5 6 7 and make sure to set the old 7 to all -1's
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.