View Single Post
Old 12-30-2000, 03:37 AM   #4
Paul Victorey
Member (12 bit)
 
Paul Victorey's Avatar
 
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
I don't see why you need to use the static keyword at all... Maybe I'm not thinking right as it's 3:30 AM here, but I don't think I've ever seen static variables used outside of a class/struct.

The only reason I know of to use static variables is, when used before a data member in a class, it forces the value of that data member to be the same amongst all instances of the class. I.e., if you use this code:


class MyClass{
public static int data;
};

MyClass myObject1;
MyClass myObject2;

//At this point, myObject1.data and myObject2.data must
//always be the same, as they are 2 ways to refer to the
//same variable.


By definition any global variable will always act this way -- as there can be only one instance of the global variable -- so what, then, is the static supposed to do, anyhow? Maybe if I knew why you needed it, I could offer more advice.

(Sorry, BTW, if this makes no sense, or is really dumb. It's 3:30 AM, that's my excuse and I'm sticking to it)

[Edited by Paul Victorey on 12-30-2000 at 04:40 AM]
__________________
Paul M. Victorey
------------------
I am not responsible for any problems that may arise as a result of following my advice. This includes, but is not limited to, computer failure, loss of data, nuclear war, famine, boils, no clean laundry, your daughter running off with a biker gang, or armageddon. Take my advice at your own risk.
Paul Victorey is offline   Reply With Quote