c++ - Debug Assertion Failed! Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) In program ended -
im doing physics simulation , have 2 classes, simulation
, renderer
. need have them reference each other , problem when pass reference renderer
happens.
here code:
renderer.cpp renderer::renderer(simulation* _sim) { sim = new simulation(*_sim); } renderer::~renderer() { delete sim; } renderer.hpp class renderer { private: simulation* sim; public: renderer(simulation* _sim); ~renderer(); };
edit:
here requested code (the thing draw it):
renderer.cpp void renderer::draw() { for(auto obj : sim->objects) { glbegin(gl_points); for(auto p : obj) { glcolor3f(colors[p.id][0], colors[p.id][1], colors[p.id][2]); glvertex2f(p.x,p.y); } glend(); } }
the error coming sim = new simulation(*_sim);
, if remove it, no errors. no ideas of how fix it?
fixed problem myself. double delete problem. simulation deleted when gonna delete it. i've removen delete sim
.
Comments
Post a Comment