Перенос страниц
This commit is contained in:
parent
4d57446057
commit
4c954c9186
129 changed files with 14 additions and 15 deletions
|
@ -0,0 +1,60 @@
|
|||
import std.stdio : writeln;
|
||||
|
||||
class Shape
|
||||
{
|
||||
protected string _name;
|
||||
abstract void print();
|
||||
}
|
||||
|
||||
class DBObject
|
||||
{
|
||||
protected string _name;
|
||||
abstract void print();
|
||||
void saveState()
|
||||
{
|
||||
writeln(_name);
|
||||
}
|
||||
}
|
||||
|
||||
class StorableShape : Shape
|
||||
{
|
||||
private class MyDBObject : DBObject
|
||||
{
|
||||
this(string name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
override void print()
|
||||
{
|
||||
writeln(_name);
|
||||
}
|
||||
|
||||
final override void saveState()
|
||||
{
|
||||
writeln(this.outer._name, "; ", _name);
|
||||
}
|
||||
}
|
||||
|
||||
private MyDBObject _store;
|
||||
alias _store this;
|
||||
|
||||
this(string outName, string inName)
|
||||
{
|
||||
_name = outName;
|
||||
_store = new MyDBObject(inName);
|
||||
}
|
||||
|
||||
override void print()
|
||||
{
|
||||
writeln(_name);
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
auto s = new StorableShape("first", "second");
|
||||
s.print(); // StorableShape._name
|
||||
s._store.print(); // StorableShape.MyDBObject._name
|
||||
s.saveState(); // StorableShape._name and StorableShape.MyDBObject._name
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue