الرئيسية > lang > createstatic 
 en fr de es it nl pl pt pt_BR mk sq ca hu cs tr fa id vi ko ja ru zh zh_TW eo
السابق  التالي  تحرير  إعادة تسمية  تراجع  بحث  الإدارة  
المستندات  
تحذير! هذه الصفحة لم يتم ترجمتها.  See english version 
CREATE STATIC
CREATE STATIC

These keywords, when placed alone at the beginning of a class file, tells the interpreter that when applying non-static symbols to the name of the class, an automatic hidden instance of it will be created on the fly.

This feature allows you to implement the object-oriented programming singleton pattern.

If you use this feature, the class constructor (the special منهج _new) will be called with no parameters.

This feature is already used internally by the Form and the Settings classes.

Here are the first 13 lines (are you superstitious?) of the Settings class code:

مثال

' Gambas class file
EXPORT
CREATE STATIC

PRIVATE $sPath AS String
PRIVATE $sTitle AS String
PRIVATE $cSlot AS NEW Collection
PRIVATE $bModify AS Boolean

PUBLIC SUB _new(OPTIONAL Path AS String, OPTIONAL Title AS String)

  DIM hFile AS File
  DIM sLine AS String
...

إنظر أيضا

Object & Class Management, CREATE PRIVATE