Delphi的'private'子句(指令)不工作 [英] Delphi 'private' clause (directive) does not work

查看:128
本文介绍了Delphi的'private'子句(指令)不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查我的私人程序是否真的私人。但它的工作方式,它不应该。

I'm trying to check if my private procedures are really private. But it works the way it shouldn't.

请帮助我,也许我错过了关于包装应该如何工作的事情。

Please help me, maybe I missed something about how the incapsulation should work.

。我猜。但它工作。

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
    tmyclass = class
    private
      procedure one;
    end;

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure tmyclass.one;
begin
  ShowMessage('1');
end;

procedure TForm1.Button1Click(Sender: TObject);
var myclass:tmyclass;
begin
  myclass.one;
end;

end.

谢谢。 (Delphi-7,Win7 x64)。

Thank you. (Delphi-7, Win7 x64).

推荐答案

单位

使用更新版本的Delphi,您可以使用 strict private 以获得预期的行为。

With more recent version of Delp you can use strict private to get the expected behavior.

这篇关于Delphi的'private'子句(指令)不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆