sources
This commit is contained in:
parent
1d0a2964cf
commit
151d77ee54
11 changed files with 340 additions and 0 deletions
|
@ -0,0 +1,23 @@
|
|||
class Outer
|
||||
{
|
||||
int x;
|
||||
|
||||
class Inner
|
||||
{
|
||||
int y;
|
||||
|
||||
this()
|
||||
{
|
||||
x = 42;
|
||||
// x – то же, что this.outer.x
|
||||
assert(this.outer.x == 42);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
auto outer = new Outer;
|
||||
auto inner = outer.new Inner;
|
||||
assert(outer.x == 42); // Вложенный объект inner изменил внешний объект outer
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue