sv——static關鍵字

static class property

 

如果變量需要在不同的對象中共享,那麼可以把這個變成定義成靜態變量。

靜態變量在聲明對象句柄的時候就分配內存空間。

The static class properties can be used without creating an object of that type.

1

2

3

4

class Packet ;

static integer fileID = $fopen"data""r" );

Packet p;

c = $fgetc( p.fileID );

  

static class method

 

  A static method has no access to non-static members (class properties or methods), but it can directly access static class properties or call static methods of the same class.

  Access to non-static members or to the special this handle within the body of a static method is illegal and results in a compiler error.

  Static methods cannot be virtual.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章