What happens when you add elements to a data structure such as a vector while iterating over it. Can I not do this?
I tried this and it breaks:
int m
Iterators are invalidated by some operations that modify a std::vector.
std::vector
Other containers have various rules about when iterators are and are not invalidated. This is a post (by yours truly) with details.
By the way, the entrypoint function main() MUST return int:
main()
int
int main() { ... }