32 lines
458 B
D
32 lines
458 B
D
class Widget
|
|
{
|
|
this(Widget source)
|
|
{
|
|
|
|
}
|
|
|
|
Widget duplicate()
|
|
{
|
|
return new Widget(this); // Выделяет память и вызывает this(Widget)
|
|
}
|
|
}
|
|
|
|
class TextWidget : Widget
|
|
{
|
|
this(TextWidget source)
|
|
{
|
|
super(source);
|
|
}
|
|
|
|
override TextWidget duplicate()
|
|
{
|
|
return new TextWidget(this);
|
|
}
|
|
}
|
|
|
|
void main()
|
|
{
|
|
TextWidget tw;
|
|
TextWidget clone = tw.duplicate();
|
|
}
|