AGB  ·  Datenschutz  ·  Impressum  







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

Kann Klasse von Record erben?

Ein Thema von MisterNiceGuy · begonnen am 15. Dez 2009 · letzter Beitrag vom 16. Dez 2009
Antwort Antwort
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#1

Re: Kann Klasse von Record erben?

  Alt 16. Dez 2009, 17:22
Zitat von MisterNiceGuy:
Ich will eine TRect-Klasse haben weil ich diese, falls sie nicht gefüllt ist auf = nil überprüfen kann, bzw ihr einen weiteren Parameter verpassen kann der sagt ob sie initialisiert ist oder nicht.

Leider ist das mit dem "kopieren" aus dem Record nicht so leicht. Folgendes bringt eine Fehlermeldung "end erwarter aber case gefunden"

Delphi-Quellcode:
type TjfRect = class
  case Integer of
    0: (Left, Top, Right, Bottom: Integer);
    1: (TopLeft, BottomRight: TPoint);
end;
Kein Problem wenn man ein bisschen überlegt

Delphi-Quellcode:
TjfRect = class
private
  FLeft, FTop, FRight, FBottom: Integer;
public
  property Left: Integer read FLeft write FLeft;
  property Top: Integer read FTop write FTop;
  property Right: Integer read FRight write FRight;
  property Bottom: Integer read FBottom write FBottom;
 
  property TopLeft: TPoint read GetTopLeft write SetTopLeft;
  property BottomRight: TPoint read GetBottomRight write SetBottomRight;
end;

function TjfRect.GetBottomRight: TPoint;
begin
  Result := Point(FRight,FBottom);
end;

function TjfRect.GetTopLeft: TPoint;
begin
  Result := Point(FLeft,FTop);
end;

procedure TjfRect.SetBottomRight(const Value: TPoint);
begin
  FRight := Value.X;
  FBottom := Value.Y;
end;

procedure TjfRect.SetTopLeft(const Value: TPoint);
begin
  FLeft := Value.X;
  FTop := Value.Y;
end;
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
Antwort Antwort


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 11:47 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