rt

解决方案 »

  1.   

    关于 pascal和c++的区别,你看看这个帖子,可能有帮助。http://expert.csdn.net/Expert/topic/1005/1005451.xml?temp=.1279261
      

  2.   

    耙子的这个贴子不错,不过没说明object pascal的静态成员变量问题。继续等待孤枕难眠中
      

  3.   

    写的不错,Object Pascal 没有直接用Static申明静态变量的实现类似的功能只能const在之前用{J+}指令打开Const申明的变量将不可以改变,{J-}指令打开Const申明的变量将可以改变,基本上是静态变量的概念了
      

  4.   

    在声明的前面加一个Class关键字,就可以实现类似的功能了!!!
      

  5.   

    Writeable typed constants
    ------------------------------
    Type Switch
    Syntax {$J+} or {$J-}
    {$WRITEABLECONST ON} or {$WRITEABLECONST OFF}
    Default {$J-}
    {$WRITEABLECONST OFF}
    Scope Local
    The $J directive controls whether typed constants can be modified or not. In the {$J+} state, typed constants can be modified, and are in essence initialized variables. In the {$J-} state, typed constants are truly constant, and any attempt to modify a typed constant causes the compiler to report an error.
    Writeable consts refers to the use of a typed const as a variable modifiable at runtime. For example:const   foo: Integer = 12;
    begin
        foo := 14;end.With $WRITEABLECONST OFF, this code produces a compile error on the assignment to the foo variable in the begin..end block.  To fix it, change the const declaration to a var declaration.In early versions of Delphi and Borland Pascal, typed constants were always writeable, corresponding to the {$J+} state. Old source code that uses writeable typed constants must be compiled in the {$J+} state, but for new applications it is recommended that you use initialized variables and compile your code in the {$J-} state.
      

  6.   

    我觉得C++的静态变量相当于private块下面生命的变量,是不是可以这样理解呢?