Jump to content
  • Advertisement

Archived

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

Subotron

Acces violation error when using GetTickCount in class pointer

This topic is 5583 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 made a FPS class, which is used in my app by making a pointer to the class (CFPSClass* g_classPointerFPS) But the returnFPS function of the class uses GetTickCount(); Now when I access the FPS class by using the pointer I get an Access violation error. When I don''t make it a pointer it works though (so instead of CFPSClass* g_classPointerFPS you get CFPSClass g_classFPS) Is there a way to use GetTickCount() in a pointer class? I really need it to be a pointer :S Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
problem is not with gettickcount, but with your class. are you allocating an instance of it with new at some point?

Share this post


Link to post
Share on other sites
Since you probably are only going to ever have one instance of that class, you probably don''t need a pointer, but if you insist, make sure it looks like

  
CFPSClass* g_classPointerFPS = new CFPSClass;
// do stuff

g_classPointerFPS->returnFPS();
// do more stuff

delete g_classPointerFPS;

and not

  
CFPSClass* g_classPointerFPS;
// do stuff

g_classPointerFPS->returnFPS();
// do more stuff

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!