我想定义一个集合,但他里面的内容是另外两个集合,如何定义和使用啊?例如   ToneType = set of (1,2,3,4,5,6);
  TtwoType = set of (a,b,c);
  TUnType = (ToneType ,TtwoType);这样定义肯定是错的,请教高手如何定义上诉结构啊!

解决方案 »

  1.   

    TUnType :=ToneType +TtwoType
      

  2.   

    TUnType :=ToneType +TtwoType
    ==============================
    类型是不能并的,只能定义了变量后再并
      

  3.   

    只能同类型的集合才能合并:type
      NumSet = 0..255;
      StrSet = 'a'..'z';var
      NumSet1, NumSet2: set of NumSet;
      StrSet1, StrSet2: set of StrSet;
    begin
      NumSet1 := [0, 1, 3];
      NumSet2 := [10, 30];
      NumSet1 := NumSet1 + NumSet2;  StrSet1 := ['a', 'b'];
      StrSet2 := ['z'];
      StrSet1 := StrSet1 + StrSet2;
      

  4.   

    不了解lz这样定义后怎么使用,有2种方法供参考:
    第一种,TUnType的值范围为#0..#255,ToneType和TtwoType是它的子集:
      TUnType = set of char;
      ToneType = set of #1..#6;
      TtwoType = set of 'a'..'c';
    第二种,TUnType定义为记录:
      ToneType = set of #1..#6;
      TtwoType = set of 'a'..'c';
      TUnType = record
        one: ToneType;
        two: TtwoType;
      end;