Differenze tra le versioni di "CREATE PRIVATE...CREATE STATIC"

Da Gambas-it.org - Wikipedia.
m
m
Riga 12: Riga 12:
  
 
A class or object, can be considered in <span class="plainlinks"> [http://thebeginnerslens.com/iphone-camera-tips-and-iphone-photography <span style = "color: black; font- weight: normal; text-decoration: none! important; background: none! important; text-decoration: none; "> how to use iphone camera</span>] simply as a <span class="plainlinks">[http://featherranch.com/ <span style="color:black;font-weight:normal; text-decoration:none!important; background:none!important; text-decoration:none;">dog training</span>] collection of features that characterize the use within a program. As a variable, once created and instantiated in the procedure, a content and assumes a shape in real memory, just as is done for a class.
 
A class or object, can be considered in <span class="plainlinks"> [http://thebeginnerslens.com/iphone-camera-tips-and-iphone-photography <span style = "color: black; font- weight: normal; text-decoration: none! important; background: none! important; text-decoration: none; "> how to use iphone camera</span>] simply as a <span class="plainlinks">[http://featherranch.com/ <span style="color:black;font-weight:normal; text-decoration:none!important; background:none!important; text-decoration:none;">dog training</span>] collection of features that characterize the use within a program. As a variable, once created and instantiated in the procedure, a content and assumes a shape in real memory, just as is done for a class.
A class can contain different element types, from simple <span class="plainlinks"> [http://www.diamondlinks.net/ <span style = "color: black; font-weight: normal; text-decoration: none ! important; background: none! important; text-decoration: none; "> Link Building</span>] complex variable functions, each time the object is created, are actually created in memory all of its elements (private and public). The program then will be returned to the point (or reference) of the new object in memory.
+
A class can contain different element types, from simple <span class="plainlinks"> [http://www.diamondlinks.net/ <span style = "color: black; font-weight: normal; text-decoration: none ! important; background: none! important; text-decoration: none; "> Link Building</span>] complex variable functions, each <span class="plainlinks">[http://tripfoundry.com/ <span style="color:black;font-weight:normal; text-decoration:none!important; background:none!important; text-decoration:none;">Trip Foundry</span>] time the object is created, are actually created in memory all of its elements (private and public). The program then will be returned to the point (or reference) of the new object in memory.
 
The use of a variable, or function, which is part of the object, it can be done by pointing to the name of the variable / function, passing first to the starting point of the <span class="plainlinks">[http://www.proposable.com <span style="color:black;font-weight:normal; text-decoration:none!important; background:none!important; text-decoration:none;">proposal software</span>] class:
 
The use of a variable, or function, which is part of the object, it can be done by pointing to the name of the variable / function, passing first to the starting point of the <span class="plainlinks">[http://www.proposable.com <span style="color:black;font-weight:normal; text-decoration:none!important; background:none!important; text-decoration:none;">proposal software</span>] class:
  

Versione delle 23:40, 21 feb 2012

CREATE PRIVATE CREATE STATIC


[Translation from the official page of Gambas] These two keywords, enter the code at the beginning of a class, indicate that the Gambas interpreter class can not be instantiated. This mode is used for the construction of classes, the fathers of other classes.

As already Virginia reckless driving mentioned in the Objects and Classes, a class can be buy pistachios derived from another top class, inheriting the public features and functionality. The purpose of this logic is part of the fresno carpet cleaning concept of object (or class), common to all object-oriented Phuket property languages.

As in other articles, I do not want to start a discussion here on the concept of class, but somehow I'll try to explain the workings of some Susan Lim Features of Gambas, linking top weight loss pills this to some references and general concepts.

A class or object, can be considered in how to use iphone camera simply as a dog training collection of features that characterize the use within a program. As a variable, once created and instantiated in the procedure, a content and assumes a shape in real memory, just as is done for a class. A class can contain different element types, from simple Link Building complex variable functions, each Trip Foundry time the object is created, are actually created in memory all of its elements (private and public). The program then will be returned to the point (or reference) of the new object in memory. The use of a variable, or function, which is part of the object, it can be done by pointing to the name of the variable / function, passing first to the starting point of the proposal software class:


  DIM AS NuovaClasse Windowdeclaration of a class of type Window   ...   () NuovaClasse = NEW Window creation of the class in memory   ...   NuovaClasse.Resize (x, y)using a method (or function) of the new class   ...   NuovaClasse.Caption = "Title"using a new class of property   ...   DIM AS NuovoPuntatore Window   NuovoPuntatore NuovaClasse =creating a new pointer to an existing class


The logic of the objects used to define a set of distinct characteristics related to the object itself.

If we associate this logic to the real world, we can take a simple example: imagine we describe a pencil (or pencil), using a class calledpencil


  'Gambas class file'   '   Pencil CLASS   .   Object INHERITS''derived from the parent class   .   LunghezzaMatita PUBLIC AS Integer''characteristic property of the object


Note: It must be remembered that in Gambas, all objects (or classes) are derived from the base class Object, and for graphical objects there is a specialized class in Control (which also comes from Object).

Returning to our example, we have a class calledpencil, derived from the base classobject. From this it receives all the features, including the basic ones here of creation and destruction of the object itself. The classPencilwe added, compared to Object, property LunghezzaMatita', which in our simple example defines the uniqueness of the new object, in this case LunghezzaMatita aims to define, precisely, the size of a pencil . In this way we have done is define a specialized, but still has all the requirements. We know that in realityThere are a pencil of every kind and loan modification color, so we need to define a new definition ofpencil, to correspond to a real object. Suppose you want to create apencilthat can take on different colors:


  'Gambas class file'   '   MatitaColorata CLASS   .   INHERITS PencilPencilderived from the parent class   .   AS PUBLIC Color Color''feature of the new object


In this example we have created a new objectMatitaColorata,Pencil by deriving from the upper class. This new class inherits thepublic propertyLunghezzaMatita of the upper class, but adds an additional property:Color. The beauty of this logic is that we must not re-write the code to create a pencil, because the code is already included in the upper class, and the child class automatically inherits it. The new class has become a specialized class of the classPencil.

One of the fundamental purposes of logical object, is precisely that of not having to repeatedly write the same code, and an object can be reused several times for different situations. In this way we can create different objects, derived from the same source, but have different specializations. Unlike older versions of Gambas, in these latest releases there seems no limit nll'inerenza of classes and subclasses (in some of my programs I have used up to 20 subclasses ...).

Returning to the keywordsCREATE PRIVATE andCREATE STATIC; admit for a moment that the base classPencilcan not be directly used, because it is not equipped with the necessary functional characteristics of a real pencil (do not even know if the point ...).



CREATE PRIVATE'

Since the base class can not be used directly Pencil, Gambas say to block it, and make it useful only for the creation of the lower classes:


  'Gambas class file'   '   Pencil CLASS   .   Object INHERITS''derived from the parent class Object   .   CREATE PRIVATEdefinition of a class instance   .   LunghezzaMatita PUBLIC AS Integer''feature of the new object


The phraseCREATE PRIVATE informs the Gambas interpreter,pencilthat the class can neither be created nor instantiated within the program. At this point, if we want to create a real pencil, you create another object, that takes real properties (eg color):


  'Gambas class file'   '   MatitaRossa CLASS   .   INHERITS PencilPencilderived from the parent class   .   PUBLIC READ AS Color Colorcharacteristic property of the new object   .   Public Function Colore_Read ()method to return the property value of color     RETURN Color.Red''return value   END'


The new class MatitaRossa no more than the base class pencil, but with a special feature: it is red. The new proprierà color (which is set to read-only), Red returns the constant value, the base class static Color Gambas.



CREATE STATIC

The phraseCREATE STATIC, unlike its predecessor, says all'inteprete Gambas that the class in question, besides not being able to be created, and then instantiated, must be created in memory automatically, and that should be accessible already at boot program. This means that, unlike a normal class or private class (see above), the new class is already available and active, without any vending machines instructions to create. Examples in gambas, Forms are the classes and Settings, which are directly used in practice are automatically created on the fly ... As withCREATE PRIVATE, the syntax must be at the beginning of the class code, or immediately after an instruction INHERITS.


  'Gambas class file'   '   Pencil CLASS   .   CREATE STATICdefinition ofstatic class


  'Gambas class file'   '   MatitaRossa CLASS   .   INHERITS Pencil   .   CREATE STATIC definitionunderstatic class


Unlike the made forCREATE PRIVATE, the new class MatitaRossayestakes on the properties of the upper classPencil, but there is Bisonó to create it, because he does automatically the Gambas interpreter to having the program, and the class is immediately available for use.

It 'obvious that, in this case, it is not possible to have, and then create multiple instances of the same object, so this approach has the basic purpose of: maintaining an object-oriented program management, and' Using a static class as a kind of container-specific features, then it is a bit like the form in Gambas.