east1203

导航

sv——static关键字

 

 

static class property

 

如果变量需要在不同的对象中共享,那么可以把这个变成定义成静态变量。

静态变量在声明对象句柄的时候就分配内存空间。

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

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.

 

 

posted on 2019-09-27 15:21  east1203  阅读(841)  评论(0编辑  收藏  举报