Jump to content
  • Advertisement
Sign in to follow this  
0x544849415A

[C++] Weird problems with class variables

This topic is 2600 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

Hello,

I was working the whole morning to get this to work, but failed, however it's mainly about the public bool m_bMainMenu, it is defined in the class header and I'm able to read and write on it in the constructor, but when using this variable in another public method it gives me an debugging error:

unhandled exception at 0x008eb0b4 ... access violation while reading at postion 0x000000154
[font="arial, helvetica, sans-serif"] [/font][font="arial, helvetica, sans-serif"]Source[/font]
[font="arial, helvetica, sans-serif"] [/font][font="arial, helvetica, sans-serif"] help would be appreciated,

Regards.[/font]

Share this post


Link to post
Share on other sites
Advertisement
Its douptful that your problem is the variable. This only happens during the constructor? I assume you've tried single stepping through your code, how far do you get before this exception is thrown? What callbacks have you setup for GLUT? Perhaps the exception is being throw from somewhere in one of those.

I would first split up your constructor and the initialisation since your entire program will be running inside the constructor. Pste your main function too (where you create this CGraphics class.

Share this post


Link to post
Share on other sites
0x000000154 is close to 0x00000000, which is a common bit pattern for the NULL pointer constant. So, you are probably calling onWindowDraw() on a NULL pointer.

Ensure all your objects and any global pointers are properly initialised before passing your function pointers to GLUT.

Share this post


Link to post
Share on other sites
Ahh... yes, right, pGraphics was actually the pointer to that class at the main source file, I called some functions of that CGraphics class when the class wasn't finished constructing, thus the null pointer. Thank you!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!