下面是我今天写的singleton模式,请大家斧正。
PM表示ProgramManager,存放所谓全局变量(此例只有BoxTitle),和一些全局性的处理。

file://--------------------------------------------------------------------
unit uApplication;


interface


type
  TPM = class(TObject)
  private
    constructor Create;
  public
    destructor Destroy;override;
    class function GetSelf: TPM;

    话框标题
    public BoxTitle:string;
  end;

implementation

var
    m_self:TPM;

constructor TPM.Create;
begin
end;

destructor TPM.Destroy;
begin
end;

class function TPM.GetSelf():TPM;
begin
    if m_self=nil then m_self:=TPM.Create;
    Result:=m_self;
end;


end.

用程序
----------------------------------------
只要引用了此单元,在程序的任何一个地方,都可以如此访问
TPM.GetSelf().BoxTitle:="xxx 系统";

frmA.caption:=TPM.GetSelf().BoxTitle;

我不能确定的是,在implementation中定义的var m_self:TPM来代替c++中的static data member 是否合适。。。