Главная страница
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.044 c
4-1105649578
Scained
2005-01-13 23:52
2005.03.13
Как перевести Ring3 в Ring0


4-1107204385
rks
2005-01-31 23:46
2005.03.13
Программирование USB


8-1101130602
Axer
2004-11-22 16:36
2005.03.13
Ещё вопросик по BASS.DLL


4-1106922134
JaDS
2005-01-28 17:22
2005.03.13
деректива message


14-1108642779
wicked
2005-02-17 15:19
2005.03.13
dot net - с чего начать?...