Instance

From REALbasicWiki

Jump to: navigation, search
Overall article skill Skill ranges from beginner (green) to expert (red)

An instance is the real in-memory part corresponding to a class (or an object, a control... which are classes too ). The creation of an instance from a class is called instantiation.

[edit] What is it ?

Think of a "car class" which describes all that you need to build a real car. It allows for some custom properties such as the color, the engine type... But it is still something that could exist but that you cannot drive.

Now if you create an instance of this car class, (in REALbasic, this would be myCar = new Car) you will end up with a real car and, if you provided the properties you wanted, your car will have your favorite color, the engine you want...

From a REALbasic point of view, a class just describes how its instance should be, what it should do and how much memory it need whereas the instance is the real object derived from the class. So each instance occupies memory with all its own properties value, contents...

Personal tools
related