Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Ich vermisse Konstanten erst im Konstruktor initialisieren zu können (https://www.delphipraxis.net/174200-ich-vermisse-konstanten-erst-im-konstruktor-initialisieren-zu-koennen.html)

Sir Rufo 9. Apr 2013 15:50

AW: Ich vermisse Konstanten erst im Konstruktor initialisieren zu können
 
Diese beiden (Beispiel-) Units sollten veranschaulichen, was geht, und was nicht
Delphi-Quellcode:
unit BaseClass;

interface

type
  TBaseClass0 = class
  strict private
    FStrictPrivate : Integer;
  private
    FPrivate : Integer;
  strict protected
    FStrictProtected : Integer;
  protected
    FProtected : Integer;
  public
    FPublic : Integer;

    procedure DoSomeThing; virtual;
  end;

  TBaseClass1 = class( TBaseClass0 )

  public
    procedure DoSomeThing; override;
  end;

procedure DoSomeThing( ABase : TBaseClass0 );

implementation

{ TBaseClass0 }

procedure TBaseClass0.DoSomeThing;
begin
  FStrictPrivate  := 0;
  FPrivate        := 0;
  FStrictProtected := 0;
  FProtected      := 0;
  FPublic         := 0;
end;

{ TBaseClass1 }

procedure TBaseClass1.DoSomeThing;
begin
  inherited;
  // FStrictPrivate  := 1; // nicht möglich
  FPrivate        := 1;
  FStrictProtected := 1;
  FProtected      := 1;
  FPublic         := 1;
end;

procedure DoSomeThing( ABase : TBaseClass0 );
begin
  with ABase do
    begin
      // FStrictPrivate := 3; // nicht möglich
      FPrivate := 3;
      // FStrictProtected := 3; // nicht möglich
      FProtected := 3;
      FPublic   := 3;
    end;
end;

end.
Delphi-Quellcode:
unit BaseClass2;

interface

uses
  BaseClass;

type
  TBaseClass2 = class( TBaseClass0 )

  public
    procedure DoSomeThing; override;
  end;

procedure DoSomeThing( ABase : TBaseClass0 );

implementation

{ TBaseClass2 }

procedure TBaseClass2.DoSomeThing;
begin
  inherited;
  // FStrictPrivate  := 2; // nicht möglich
  // FPrivate        := 2; // nicht möglich
  FStrictProtected := 2;
  FProtected      := 2;
  FPublic         := 2;
end;

procedure DoSomeThing( ABase : TBaseClass0 );
begin
  with ABase do
    begin
      // FStrictPrivate  := 4; // nicht möglich
      // FPrivate        := 4; // nicht möglich
      // FStrictProtected := 4; // nicht möglich
      // FProtected      := 4; // nicht möglich
      FPublic := 4;
    end;
end;

end.

Furtbichler 9. Apr 2013 17:59

AW: Ich vermisse Konstanten erst im Konstruktor initialisieren zu können
 
Zitat:

Zitat von Sir Rufo (Beitrag 1210826)
...

Zitat:

Zitat von DeddyH
...

:wall:
Ich sag ab jetzt nie wieder was. :oops:

haentschman 9. Apr 2013 18:28

AW: Ich vermisse Konstanten erst im Konstruktor initialisieren zu können
 
Zitat:

Ich sag ab jetzt nie wieder was.
...joa is denn heut scho Weihnachten ? :mrgreen:

mir war grad so, sorry... 8-)

Furtbichler 9. Apr 2013 18:42

AW: Ich vermisse Konstanten erst im Konstruktor initialisieren zu können
 
hmmm. hmmm..mhmmmhmm...hmmhmfgfds:roll:


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:46 Uhr.
Seite 3 von 3     123   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz