Here is the definition:
In object-oriented programming with classes, an instance variable is a variable defined in a class (i.e. a member variable) // I get this part
, for which each object of the class has a separate copy. // This part I don’t get.
How can an object have a seperate copy? a seperate copy of what?
Sorry for asking basic questions, I’m still a noob.
Thank you
[COMMENT ANSWER]
An instance variable is a variable that has an instance for each object declared where a class variable is a single member variable for which there is only one for all objects declared of that type. Class variable uses the keyword static, where an instance variable does not!
[ORIGINAL]
When you define a class, it has member declarations.
An object isn’t truly instantiated (or given memory space) until a variable of that class type is defined.
If you then define two of that class type, those objects are given their own memory spaces, and indeed each member of each object has its own memory (thus 2 separate instantiations of that object).
Now each grouping of data (within the objects) can and really is manipulated separately.
Class Variable:
http://en.wikipedia.org/wiki/Class_variable
Instance Variable:
http://en.wikipedia.org/wiki/Instance_variable