c++ - delete pointers, VC++, Debug Assertion Failled -
i having error "debug assertion failed" @ run time code below. compiled code mvc++ 2010, in debug mode when click on retry on error window directs me file dbgdel.cpp @ line
_asserte(_block_type_is_valid(phead->nblockuse));
when comment line
delete result;
in code, error disappears...
i appreciate understand problem. sould delete pointer result, new used create clone method (sorry can't post full code , big)
thanks help
/***code****/ ######## file: drawshapebase.cpp ... ... base* drawshapebase::setoutput(base* data) { return (data->clone()); } .... base* drawshapebase::draw(base* data){ base* result = setoutput(data); ... ... return result; } /*##############*/ file: derived.cpp ... ... base* derived::clone() { base* b = new derived(*this); return b; } ... ... /*##############*/ file base.h public: base(); virtual ~base(); virtual base* clone(void) = 0; .... /*##############*/ main.cpp ... ... base* data = new derived(); drawbase* dr = new drawshapebase(); base* result = dr->draw(data); delete data; delete result; delete dr; ...
Comments
Post a Comment