Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.03.13;
Скачать: CL | DM;

Вниз

Не хочет вызываться нужный конструктор класса   Найти похожие ветки 

 
Мирон ©   (2005-03-01 00:44) [0]

Есть такое дело:

...
TAboutDocument = class(TDocument)
private
 FList: TList;
public
 constructor Creare; override;
 property List: TList read FList;
end;

TDocumentClass = class of TDocument;
...

TRegime = class(TObject)
private
...
 FDocument: TDocument;
 function DocumentClass: TDocumentClass; virtual; abstract;
...
public
 constructor Create;
end;

TAboutRegime = class(TRegime)
...
 function DocumentClass: TDocumentClass; override;
...
end;

constructor TAboutDocument.Create;
begin
 inherited;
 FList := TList.Create;
end;

constructor TRegime.Create;
begin
 inherited;
 FDocument := DocumentClass.Create;
 ...
end;

function TAboutRegime.DocumentClass: THTMLDocumentClass;
begin
 Result := TAboutDocument;
end;


Так вот, во время TAboutRegime.Create при выполнении строки FDocument := DocumentClass.Create;  конструктор TAboutDocument не выполнятеся вообще... Хотя после этой строки FDocument <> nil, но в то же время FDocument.List = nil... Не пойму, почему такое твориться...


 
Димон   (2005-03-01 00:48) [1]

ты не опечатался
creare или create?


 
Мирон ©   (2005-03-01 00:51) [2]

Димон   (01.03.05 0:48) [1]
опечатался... Create...


 
Мирон ©   (2005-03-01 00:52) [3]

блин, и внизу...

читать правильно

function TAboutRegime.DocumentClass: TDocumentClass;
begin
Result := TAboutDocument;
end;


 
Юрий Зотов ©   (2005-03-01 01:48) [4]

Вот так все работает. Практически то же самое, что и у Вас, (только немного причесано), поэтому в чем причина - непонятно. Вероятно, в том коде, который не приведен.

type
 TDocument = class
   constructor Create; virtual;
 end;

 TDocumentClass = class of TDocument;

 TAboutDocument = class(TDocument)
 private
   FList: TList;
 public
   constructor Create; override;
   destructor Destroy; override;
   property List: TList read FList;
 end;

 TRegime = class
 private
   FDocument: TDocument;
 protected
   class function DocumentClass: TDocumentClass; virtual; abstract;
 public
   constructor Create;
   destructor Destroy; override;
 end;

 TAboutRegime = class(TRegime)
 protected
   class function DocumentClass: TDocumentClass; override;
 end;

 TForm1 = class(TForm)
   procedure FormClick(Sender: TObject);
 end;

{ TDocument }

constructor TDocument.Create;
begin
 inherited Create
end;

{ TAboutDocument }

constructor TAboutDocument.Create;
begin
 inherited;
 FList := Tlist.Create
end;

destructor TAboutDocument.Destroy;
begin
 FList.Free;
 inherited
end;

{ TRegime }

constructor TRegime.Create;
begin
 inherited;
 FDocument := DocumentClass.Create;
end;

destructor TRegime.Destroy;
begin
 FDocument.Free;
 inherited
end;

{ TAboutRegime }

class function TAboutRegime.DocumentClass: TDocumentClass;
begin
 Result := TAboutDocument
end;

{ TForm1 }

procedure TForm1.FormClick(Sender: TObject);
begin
 TAboutRegime.Create.Free
end;



Страницы: 1 вся ветка

Текущий архив: 2005.03.13;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.026 c
3-1108442952
Tigerr
2005-02-15 07:49
2005.03.13
Удаление записи из БД


11-1091803299
Дмитрий Галин
2004-08-06 18:41
2005.03.13
Ошибка компиляции после установки компонента


14-1109060470
Чеширский_Кот
2005-02-22 11:21
2005.03.13
Разбирающимся в ноутбуках


14-1109074987
}|{yk
2005-02-22 15:23
2005.03.13
Футбольный сезон 2005


14-1108746596
Kolan
2005-02-18 20:09
2005.03.13
Пошлите меня на нейронные сети :)