Acces violation error when using GetTickCount in class pointer

Started by
2 comments, last by Subotron 21 years, 2 months ago
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!
Advertisement
problem is not with gettickcount, but with your class. are you allocating an instance of it with new at some point?
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 stuffg_classPointerFPS->returnFPS();// do more stuffdelete g_classPointerFPS;  

and not

  CFPSClass* g_classPointerFPS;// do stuffg_classPointerFPS->returnFPS();// do more stuff  
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
Oops... that was my problem indeed... but yes I really need 2 of ''em so tnx a lot for solving it!

This topic is closed to new replies.

Advertisement