Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


C++ question.

This topic is 5295 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites
Syntactically everything looks ok.

Stating the obvious, make sure newOutputArea is not 0.

Step through the code as see where it bombs.

Share this post

Link to post
Share on other sites
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?


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!