Reputation: 567
So, I was trying to make a list of the different types of variables and wanted to confirm if my classification was correct or not.
Three types, I say:
1.Static/Class
2.Instance
3.Global
I understand that global variables are declared outside the class definition but static variables must be declared (not necessarily instantiated) within the class definition. Are there any more important differences between the class and global variables?
Upvotes: 1
Views: 135
Reputation: 4873
A class is not synonymous with a static variable. Any variable can be declared static. Where it's declared will impact what it actually means.
A class really isn't a variable type, it's how you define a new variable type. int
is a type of variable, and Foo
is a type of variable once you've defined it with the class keyword.
Instance really makes no sense. You have an instance of a variable, (e.g. an instance of an integer) but that's not a variable type.
In the terms of "types of variables", as you're looking at them, I would say there are two types: global and local. Static just has too many meanings to be included in that list.
Upvotes: 1