Hello,
I'm fairly new to visual c++ and am currently working my way thourgh a few examples of windows programming.
Anyway, the curent example I'm putting together is a very simple drawing application (the kind of thing you find in all the learn visual c++ books).
The problem I'm facing is everytime I try and delete an object the app gives me one of those error messages where I can send a report to microsoft and the app dies.
Basically
I'm creating a new object like so
CElement element;
element = new CLine(start, end, color);
m_pTempElement = &element;
This part works fine, and the element is drawn ok.
The problem comes when I try and..
delete m_pTempElement
m_pTempElement = 0;
the program crashes on the delete line.
Any ideas? Am I doing something really stupid that should be obvious?
Thanks.
ps. Its being compiled by vc++ 6 running on windows xp if this makes any difference.
I'm fairly new to visual c++ and am currently working my way thourgh a few examples of windows programming.
Anyway, the curent example I'm putting together is a very simple drawing application (the kind of thing you find in all the learn visual c++ books).
The problem I'm facing is everytime I try and delete an object the app gives me one of those error messages where I can send a report to microsoft and the app dies.
Basically
I'm creating a new object like so
CElement element;
element = new CLine(start, end, color);
m_pTempElement = &element;
This part works fine, and the element is drawn ok.
The problem comes when I try and..
delete m_pTempElement
m_pTempElement = 0;
the program crashes on the delete line.
Any ideas? Am I doing something really stupid that should be obvious?
Thanks.
ps. Its being compiled by vc++ 6 running on windows xp if this makes any difference.