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

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -