随便问一下 ,interface的作用是什么??public 和 published的区别是什么?

解决方案 »

  1.   

    interface 是提供接口的吧,PUBLIC和PUBLISHED的区别我也想知道啊,因为我觉得它们没有区别
      

  2.   

    还是先看看pascal的基本知识吧。
      

  3.   

    帮楼主顶!
    欢迎加入DELPHI!
      

  4.   

    欢迎加入Delphi !! hehe^^Interface是接口呀,作用吗 hehe^^ .... 实现多重继承、COM.....好多地方要用是Delphi划时代的一个标志public和published的区别是用在属性编辑器时就会有不同,主要用在Delphi控件的编写上published主要用来声明(发布)事件,属性public主要用来声明(发布)方法大概就是这样吧,hehe^^
      

  5.   

    published主要用来声明(发布)事件,属性public主要用来声明(发布)方法欢迎
      

  6.   

    CDSoftwareWj(95927)好啊。。非常感谢你:)
      

  7.   

    呵呵,,不错DELPHI慢慢学,不过你已经会散分了。。有前途。。
    热烈欢迎啊。。
      

  8.   

    从此决定在delphi混了。。发现java做时时系统,和windows GUI上效率上确实没delphi好不过java还是不错的。。希望delphi们也来学学java吧:) 题外话啦。。随便做个广告。欢迎到java版拉^_^
      

  9.   

    about Published and Public reserve word:
    Published members have the same visibility as public members. The difference is that runtime type information (RTTI) is generated for published members. RTTI allows an application to query the fields and properties of an object dynamically and to locate its methods. RTTI is used to access the values of properties when saving and loading form files, to display properties in the Object Inspector, and to associate specific methods (called event handlers) with specific properties (called events).Published properties are restricted to certain data types. Ordinal, string, class, interface, and method-pointer types can be published. So can set types, provided the upper and lower bounds of the base type have ordinal values between 0 and 31. (In other words, the set must fit in a byte, word, or double word.) Any real type except Real48 can be published. Properties of an array type (as distinct from array properties, discussed below) cannot be published.Some properties, although publishable, are not fully supported by the streaming system. These include properties of record types, array properties of all publishable types, and properties of enumerated types that include anonymous values. If you publish a property of this kind, the Object Inspector won’t display it correctly, nor will the property’s value be preserved when objects are streamed to disk.
    All methods are publishable, but a class cannot publish two or more overloaded methods with the same name. Fields can be published only if they are of a class or interface type.
      

  10.   

    about interface:
    An object interface—or simply interface—defines methods that can be implemented by a class. Interfaces are declared like classes, but cannot be directly instantiated and do not have their own method definitions. Rather, it is the responsibility of any class that supports an interface to provide implementations for the interface’s methods. A variable of an interface type can reference an object whose class implements that interface; however, only methods declared in the interface can be called using such a variable.Interfaces offer some of the advantages of multiple inheritance without the semantic difficulties. They are also essential for using distributed object models. Custom objects built that support interfaces can interact with objects written in C++, Java, and other languages.
      

  11.   

    拜托
    上面的去看看基础吧(我还在看呢)
    Delphi5开发人员指南 就可以了
    ------------
    最好是写程序,才能理解上面 基本概念的 含义
    ----------
    use unit1;interface
    const
      //常量声明
    type
      //类声明
      //函数声明
      //过程声明
      //等声明var
      //全局变量声明
    implement
      //其他类声明
      //其他函数声明
      //其他过程声明
      //等声明
      //类实现
      //函数实现
      //过程实现
      //等实现
    initialization
      //初始化
      A;
      B;
    finalization
      //结束(析构)
      B;
      A;
    end.
    Delphi里面interfaceb部分(相当于 C的 *.h 头文件)这个部分声明的东东,可以被别的单元使用
    implement 部分(相当于 C的 *.cpp 实现文件)里面的东东 ,只能被本单元使用
    声明可以在interface()或者implement 部分,但是实现必须在implement
    对于非组件(一般的类,不能放到From上面的类),published基本没有什么用处,此时相当于public,所以对于这种类型的东东,一般是没有published部分的,二者的对外可见性是一样的
    ------
    对于组件,有published的,那么最直接的就是可以在设计期间 在属性面版 可直接修改数值,并且可立即看到结果,还可以有RTTI ,那就深入了,我也不太明白了
    ------------
    看基础去了-----------
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
      private
        { Private declarations }
      public
        { Public declarations }
      end;  dd=class
      public
        function fff:string;
      end;
    var
      Form1: TForm1;implementation{$R *.dfm}
    const
      d =0;
    type
      de=class(TObject)
      public
        function ss():string;
      end;var
      s:string;
    { dd }function dd.fff: string;
    begin
      Result:=s+inttostr(d);
    end;{ de }function de.ss: string;
    begin
      Result:=s+'  '+s;
    end;initialization
      ShowMessage('initialization');
    finalization
      ShowMessage('finalizationfinali'
      +#13+'izationfinalization'+#13+'izationfinalization'
      +#13+'izationfinalization'+#13+'izationfinalization'
      +#13+'izationfinalization'+#13+'izationfinalization'
      +#13+'izationfinalization'+#13+'izationfinalization'
      +#13+'izationfinalization'+#13+'izationfinalization'
      +#13+'izationfinalization');end.
      

  12.   

    楼主好眼熟呀、莫非是WEB的★★...
      

  13.   

    我也是刚刚开始学习delphi!一起加油吧!
      

  14.   

    关于interface,我还以为你说的是这个  type
        IIntf1 = interface
          procedure AProc;
        end;这种interface呢 hehe^^如果你问的是-----------
    unit Unit1;interfaceuses
      那么是cll007解释的那种如果是这种
      type
        IIntf1 = interface
          procedure AProc;
        end;
    那就是我解释的那种 哈哈
      

  15.   

    另要学Delphi那么《Delphi5开发人员指南》是必须要有的一本书 hehe^^
    还有就是要有 www.delphibbs.com 上的dfw.chm离线数据包,相关于 Delphi程序员的MSDN有这两个东东,你学Delphi也是差不多了。
      

  16.   

    Interface是接口呀,作用吗 hehe^^ .... 实现多重继承、COM.....好多地方要用是Delphi划时代的一个标志public和published的区别是用在属性编辑器时就会有不同,主要用在Delphi控件的编写上published主要用来声明(发布)事件,属性public主要用来声明(发布)方法
      

  17.   

    没想到随便发个帖子人气那么旺,真谢谢大家。。有空我一定常来散分啊。尤其谢谢 CDSoftwareWj(95927) 。。哈哈,我两种都想问:) 只怪太菜了:(
      

  18.   

    public
        在public声明的成员是公共的,也就是说,它们虽然是在某个类声明的,但其他类的
    实例也可以引用,相当于c语言中的外部变量
    注意:面向对象的编程思想其特征之一就是隐藏复杂性,除非必须把某个成员在不同类
    之间共享v  —般来说尽量不要把成员声明在类的public部分,以防止程序意外地不正确地修
    改了数据。
    Pulished
        在Published部分声叫的成员,其可见性与在public部分声叫的成员可见性是一样的,
    它们都是公共的,即这些成员可以被其他类的实例引用。
    public成员和published成员不同之处是published成员会产生RTTI,它能使应用程序能动态查询一个对象的数据成员和属性,也能定位它的方法。RTTI用于在存储文件和文件导入时访问属性的值,也用于在Object Inspector中显示属性,并且能为一些特定的属性(即事件)关联特定的方法(即事件处理程序)。
           PS:建议多看基础书,先,呵呵!大家一起努力!!!!
      

  19.   

    cll007(gazo) ( 的格式不错:)书嘛,我其实一直在看啦。。不好意思的说-_-!!
      

  20.   

    hehe^^ Java我在用,不过在那个领域我就是菜鸟了 哈哈totodo(土豆仙) 你在Java版是个猩猩吧 哈哈哈哈,到时候帮我哦放分给你.....(小声点,不算导粪吧... ^^!)
      

  21.   

    CDSoftwareWj(95927) :)这样子啊,,那我先表示一下啦:) 哈哈,谢谢关照:)