请教几个语法问题:
1: TParser = class(TObject)
TThread = class
这两种定义有什么区别?
2:Result := inherited Items[Index];
这里的 inherited  怎么理解?
3:property Sorted;
这种没有定义类型的属性怎样理解?
4:on E:Exception do 这个E为什么不需要在方法体的开始定义?
5:unit FileCtrl platform;
这里单元名后面的platform有什么作用,而且引用这个单元总要警告?问题还很都,想扔砖头的同志给介绍本好书先^_^

解决方案 »

  1.   

    1:
    没区别
    2:继承父类的同名方法或属性
    3:Sorted属性在父类已存在了,这种方式常用于把父类属性published出来。vcl源码里到处都有这种用法。
    4:这个我也说不清了
    5:这个我还没用过
      

  2.   


    4、E应该是系统相关的(在Java、C++等语言同样有)
      

  3.   

    1:TParser = class(TObject)
    TThread = class
    这两种定义有什么区别?
    都是TObject对象,后面那个是默认为TObject2:Result := inherited Items[Index];
    这里的 inherited  怎么理解?
    inherited 继承,继承它父类的方法和属性……3:property Sorted;
    这种没有定义类型的属性怎样理解?
    zaza_bbface(我试着成熟一点~) 解析了,我就不说了4:on E:Exception do 这个E为什么不需要在方法体的开始定义?
    on E:Exception do  E:Exception 是把异常赋给了E ,我们取E.message就可以得到异常消息5:unit FileCtrl platform;
    这里单元名后面的platform有什么作用,而且引用这个单元总要警告?
    命名不谁有空格,unit FileCtrl platform;应该会出错的,这个单元应该编译不过
    所以引用这个单元会出错,如果是有窗体的文件,你可以独立成一个工程,编译不过的
      

  4.   

    关于platform 标记意思是这个单元受限于具体平台,在写跨平台的代码时,提醒你避开使用这样的单元.DELPHI自带帮助上讲了的The whole unit is tagged (using the platform hint directive) as one that contains material that may not be available on all platforms. If you are writing cross-platform applications, it may cause a problem. For example, a unit that uses objects defined in OleAuto might be tagged using the PLATFORM directiveThe $WARN UNIT_PLATFORM ON/OFF compiler directive turns on or off all warnings about the platform directive in units where the platform directive is specified.
      

  5.   

    编写activexform的时候就会看到第5个条那样的警告,平台限制
      

  6.   

    Windows还是不要这样写吧
    避开不必要的麻烦
      

  7.   

    4:on E:Exception do 这个E为什么不需要在方法体的开始定义?这个我觉得是编译器"魔法". on...do 特殊语法, 有点违反先声明后使用的原则
      

  8.   

    3:Sorted属性,只是继承父类的属性!当然不用再说明什么什么...
    4:on E:Exception do 只是到"E"中去寻找错误的信息,就像 if A In [23232,78] then 差不多
    5: 适用平台的标记!
      

  9.   

    class后面不带父类名说明直接基础TObject类,写不写都是一样的,如果想自己定义一个完全不继承内建类的新类的话用type 类名 = object (父类),比如
    Tfuck = object
      public
        Name:string;
      end;procedure TForm1.Button6Click(Sender: TObject);
    var 
        fuck:Tfuck;
    begin
        fuck.Name:='comeon';
        showmessage(fuck.Name);
    end;
    不用继承tobject的create构造方法即可直接构造实体并操作该对象成员确实都是基础