![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Вложение конструкторов
wam © (2003-02-04 18:11:00)Есть класс с несколькими конструкторами. Является ли корректным вызов конструктора1 в теле конструктора2?
malkolinge (2003-02-04 18:52:00) [1]program Project1;
// System in "..\..\..\..\Source\Rtl\Sys\System.pas";
type
TA=class
Constructor DF;
constructor ad;
end;
{ TA }
constructor TA.ad;
begin
df;
{}
end;
constructor TA.DF;
var a:Integer;
begin
a:=5;
end;
var a:ta;
begin
a:=Ta.ad;
end.
Специально брек поинт в Classes.pas на NewInstance Поставил. Экзепляр создаеться только тогда когда исп. запись
ТИмяКласса.Create ^)
Так что можно вызывать конструктор из конструктора :)))
Romkin (2003-02-04 18:36:00) [2]Корректно
wam (2003-02-04 18:31:00) [3]www = class<b/>
constructor c1;
constructor c2;
end;
constructor<b/> www.c1;
begin
inherited<b/> create;
...
end;
constructor<b/> www.c2;
begin<b/>
c1;
...
end;<b/>
Корректно это?
han_malign (2003-02-04 18:26:00) [4]When a constructor is called using an object reference(rather than a class reference), it does not create an object or return a value. Instead, the constructor operates on the specified object, executing only the statementsin the constructor’s implementation. A constructor is typically invoked on an object reference in conjunction with the reserved word inherited to execute an inherited constructor.
Игорь Шевченко (2003-02-04 18:21:00) [5]malkolinge © (04.02.03 18:20)
> Есть класс с несколькими конструкторами.
type
TMyCollClass = class
...
constructor Create;
constructor CreateBlahBlah;
end;
Я так понял...
malkolinge (2003-02-04 18:20:00) [6]
> Игорь Шевченко © (04.02.03 18:16)
> Пример в студию
Inherited Create(Aowner); :))
Игорь Шевченко (2003-02-04 18:16:00) [7]Пример в студию