A picture of memory output debugging stuff
the W, S, G are W( base class ) S( derived from base W ), G( derived from base W ). S has two extra floats that W doesn't, G has a bool W doesn't. the numbers following the letters is just sizeof( W/S/G ).
the ants are made like so
W* _ants = new S[ 6 ];
and the function giving the problem is called like so
for( int i = 0; i < 6; i++ )
{
std::cout << "Ant " << i << ": " << &_ants[ i ] << std::endl;
_ants[ i ].update();
}
update is a non-virtual method from W, though it does call a virtual method within it. I have tried removing the virtual method but it still crashes.
I'm pretty sure the problem is that the array is trying to allocate for W but since it is 8 bytes smaller than S _ants goes off track at 1 iteration, is there anyway I can get _ants to allocate the correct amount per iteration without trying to change it to S* or at least keep it on track somehow?