|
-
January 28th, 2009, 04:28 AM
#1
Value of Global variable not consistent
I have created a program wide global variable in a .h file called globals.h
Inside the .h file, the global variable is declared as:
extern float g_fFrameTime;
2 other classes use this global variable.
I included globals.h in each of these classes and declared a "float g_fFrameTime;" private data member in these 2 classes.
The first class assigns a value to g_fFrameTime via
g_fFrameTime = GetFrameTime();
while the second class uses the value of g_fFrameTime to perform some calculations.
However, when I printed out the value of g_fFrameTime of these 2 classes into 2 seperate text files respectively, their values differ. The first class which assigns a value to the global variable prints the correct value to the file (values hovering around 0.01) while the second class which is supposed to use the value of g_fFrameTime prints different values to another file (values around -9.xxxx).
Besides these 2 classes, no other classes assigns values to or uses the global variable.
What is the problem causing this inconsistency?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|