What's the difference between public and publi

2019-04-03 02:42发布

Please could someone explain me what's the difference between public and published class members in Delphi?

I tried to look at Delphi help and I understand that these members have the same visibility, but I don't understand very well how they differ and when should I use published members instead of public ones.

Thanks a lot.

8条回答
乱世女痞
2楼-- · 2019-04-03 03:39

As a side note, there is another special thing with published:

The default visibility of class members is published, so check for unsafe code like:

  TTopSecret = class(TObject)
    Name: string;
    Password: string;

    function DecryptPassword(const AValue): string;  
  public
    constructor Create(const AName, AEncryptedPassword: string);
  end; 

Name, Password and DecryptPassword() are visible 'world-wide'.

查看更多
贪生不怕死
3楼-- · 2019-04-03 03:41

Published properties will export Runtime Type Information (RTTI).

Have a look here about RTTI in Delphi

查看更多
登录 后发表回答