I have two classes, obstacle and boid, boid inherits from obstacle.
Now I want to write some functions that can work with objects of both classes, so that passing vector<boid>
does work as well as vector<obstacle>
.
When I typecast like this and try to access the size of the vector I get a number of 1840700394 instead of 60:
vector<boid>* boids; ....
cout << ((vector<obstacle>*)boids)->size() << endl;
I also tryed "reinterpret_cast" but same problem.