AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Aufrufkontext von protected

Ein Thema von Rabenrecht · begonnen am 7. Dez 2017 · letzter Beitrag vom 7. Dez 2017
 
Rabenrecht

Registriert seit: 9. Dez 2016
79 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#1

Aufrufkontext von protected

  Alt 7. Dez 2017, 13:32
Delphi-Version: 5
Man denke sich folgende Struktur:

Delphi-Quellcode:
//Unit1:
type
  A = Class
  protected
    procedure DoStuffA;
  end;

//Unit2:
type
  B = Class(A)
  private
    FOtherObject : TSomeOtherObject;
  public
    procedure DoStuffB;
  end;

implementation

procedure B.DoStuffB;
begin
  FOtherObject.InstanceOfB.DoStuffA;
end;

//Unit3
type
  C = class (A)
  private
    FOtherObject : TSomeOtherObject;
  public
    procedure DoStuffC;
  end;

implementation

procedure C.DoStuffC;
begin
  FOtherObject.InstanceOfB.DoStuffA;
end;

//Unit99
type
  TSomeOtherObject = Class
  public
    InstanceOfB : B;
  end;
Im Fall der Klasse C spukt der Compiler die Nachricht "Auf protected Symbol A.DoStuffA kann nicht zugegriffen werden".
Im Fall der Klasse B bleibt der Compiler ruhig.

Gibt es hierfür eine sinnvolle Begründung?

Geändert von Rabenrecht ( 7. Dez 2017 um 13:45 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:04 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz