I have some class where I want to use a large amount of vectors.
class Bar {
    Bar ();
    std::vector<Foo> * _grid;
    void someFunction ();
}
Bar::Bar () {
    _grid = (std::vector<Foo> *)malloc(_gridSize * sizeof(std::vector<Foo>);
    memset(_grid, 0, _gridSize * sizeof(std::vector<Foo>);
}
void Bar::someFunction () {
    int index = 0;
    std::vector<Foo> someVariable = _grid[index];
}
However, as soon as I call someFunction(), I get a vector iterators incompatible error message as soon as there is some content in _grid[index]. If the vector is empty, it works.
I've read about the error message being produced by invalidated iterators, however, since I don't change anything on the vectors at this point, I don't get what is wrong here.
 
     
    