Einzelnen Beitrag anzeigen

Benutzerbild von Zacherl
Zacherl

Registriert seit: 3. Sep 2004
4.629 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#2

AW: Problem mit Constructor/Destructor

  Alt 25. Apr 2011, 20:19
Die von dir designte Klasse ist höchst "interessant". Ich würde es so lösen:
Delphi-Quellcode:
type
  TContainer = class(TObject)
  private
    FFileName: String;
    FInvalidFile: Boolean;
  public
    procedure DoSomeThing;
    constructor Create(const FileName: String; AsReadOnly: Boolean);
    destructor Destroy;
  published
    property InvalidFile: Boolean read FInvalidFile;
  end;
Dann kannst du im Create prüfen ob die Datei geöffnet werden kann und ansonsten setzt du FInvalidFile auf true. In keinen Fall darfst du im Constructor Destroy aufrufen. Das ist tödlich
Projekte:
- GitHub (Profil, zyantific)
- zYan Disassembler Engine ( Zydis Online, Zydis GitHub)
  Mit Zitat antworten Zitat