-
_BLOCK_TYPE_IS_VALID(phead->nBlockUse)
Debug Assertion Failed. directly after exiting a member function (as I saw with step-into), happening I think in this part of my code:
drinksAtWork::drinksAtWork()
{
ch=new char;
ch="ff";
}
drinksAtWork::~drinksAtWork()
{
delete ch;
//error happens right here, which is called upon leaving main().}
The ch is a private char pointer in the drinksAtWork class.
There is only one member function which has only cout and cin.
What is wrong?
www.edwardtisdale.com
-
of Zen Hall
ch=new char;
allocates space for one char on the heap and returns the address in ch.
ch="ff";
points ch at a string literal. It no longers points to the memory on the heap and you're then trying to delete memory that you haven't allocated. You could do something like
ch=new char[3]; // for 'f','f','\0'
strcpy(ch,"ff");
and then
delete [] ch;
Popular pages
Recent additions