Problem in dynamic memory allocation

Hi there, i'm new to programming and i'm having a bit of a problem lately.
i'm writing a win32 windows application in microsoft visual c++ 2008, i have a class called Shape; in my main program i've declared a global pointer to Shape class like this:
 
Shape *shape = 0;

then in the middle of the program, when user clicks somewhere in the client area, i construct the object like so:
1
2
shape = new Shape(LOWORD(lParam),HIWORD(lParam));
shape->SetEnd(0,0);

then i compile it, there is no problem, but when the window starts an error message appear like this:
Unhandled exception at "..." in editor.exe: "some address here": Access violation writing location "some other address here"

Whats the problem,please help!
thanks a lot
It's hard to tell with so little code.
helios thanks for checkin out the thread. yea youre right.
i've simulated the same program with the exact same class in a console project and it worked properly. so i think the error is due to some settings for memory management n stuffs for windows projects or something. so the problem is not about the implementation of the class cause it worked in a console program with sample arguments sent to ctor and SetEnd function. is there any setting for the project which may be the problem here, about dynamic memory allocation and stuffs...?
That kind of error can only happen when there's a problem in the code. Usually a buffer overflow, but any misuse of memory can trigger it.
Topic archived. No new replies allowed.