Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ question.

Started by mrmrcoleman Mar 26, 2004 at 10:08 PM 3 replies 300+ views
Original Post
mrmrcoleman
mrmrcoleman
I have a class (Screen) with an internal member of type OutputArea* which is called ScreenOutputArea. To set this internal member I have a method which looks something like this.
void Screen::SetOutputArea(OutputArea* newOutputArea)
{
   ScreenOutputArea = new OutputArea(*newOutputArea);
}
ScreenOutputArea is type OutputArea*. And the OutputArea class has its copy constructor defined to accept a reference to OutputArea. At first I thought this was ok, but now I am getting a run-time crash somwhere around this class and I think this may be the problem. Can anybody see any probs with this? Thanks in advance. Mark Coleman
Colin Jeanne
Colin Jeanne
That code looks fine except that it could result in a memory leak if ScreenOutputArea is not deleted prior to this call.

Instead of "somewhere around this class" use your debugger to find out exactly where the crash is occuring.


Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud
ABC123
ABC123
Syntactically everything looks ok.

Stating the obvious, make sure newOutputArea is not 0.

Step through the code as see where it bombs.
mrmrcoleman
mrmrcoleman
Sorry guys I havent done much debugging in the past (well in fact I havent done any other than the usual MessageBox experiments) so do you think you might be able to help me out?

I am stepping through the program and when I get to a ZeroMemory function call, the compiler asks me to provide MEMSET.ASM?

However I cant locate this file anywhere on my computer?

Any ideas?

Thanks.
mrmrcoleman
mrmrcoleman
Its ok, I worked it out.

Cheers guys.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.