zoukankan      html  css  js  c++  java
  • Lazarus -Pascal常量

    2.常量

    2.1.普通常量

    仅仅下面类型可以被定义为常量
    Ordinal类型
    Set类型
    指针类型 (but the only allowed value is Nil). 
    real类型 
    Char, 
    String
    下面是定义的类型
    Const  
      e = 2.7182818;  { Real type constant. }  
      a = 2;          { Ordinal (Integer) type constant. }  
      c = ’4’;        { Character type constant. }  
      s = ’This is a constant string’; {String type constant.}  
      sc = chr(32)  
      ls = SizeOf(Longint);  
      P = Nil;  
      Ss = [1,2];  
    常量定义后是不能被赋值的,所以:
    s := ’some other string’; 
    这样编译器是会报错的。

    2.2.资源字符串

    resourcestring  
      Part1 = ’First part of a long string.’;  
      Part2 = ’Second part of a long string.’;  
      Sentence = Part1+’ ’+Part2; 
    看下面代码:
    resourcestring  
      Yes = ’Yes.’;  
      No = ’No.’;  
     
    Var  
      YesNo : Array[Boolean] of string = (No,Yes);  
      B : Boolean;  
     
    begin  
      Writeln(YesNo[B]);  
    end. 

  • 相关阅读:
    HDU-2602-Bone Collector
    HDU-1171-Big Event in HDU
    javascript概要
    核桃的数量
    P3372 【模板】线段树 1
    P3373 【模板】线段树 2
    拿糖果
    第二点五个不高兴的小明
    树的直径
    1240. 完全二叉树的权值
  • 原文地址:https://www.cnblogs.com/China3S/p/3290337.html
Copyright © 2011-2022 走看看