4 глава
This commit is contained in:
parent
e0caa7caab
commit
ec805e7f08
15 changed files with 1584 additions and 1 deletions
24
03-инструкции/src/chapter-3-9/app.d
Normal file
24
03-инструкции/src/chapter-3-9/app.d
Normal file
|
@ -0,0 +1,24 @@
|
|||
import std.math, std.stdio;
|
||||
|
||||
struct Point
|
||||
{
|
||||
double x, y;
|
||||
double norm()
|
||||
{
|
||||
return sqrt(x * x + y * y);
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
Point p;
|
||||
int z;
|
||||
|
||||
with (p)
|
||||
{
|
||||
x = 3; // Присваивает значение полю p.x
|
||||
p.y = 4; // Хорошо, что все еще можно явно использовать p
|
||||
writeln(norm()); // Выводит значение поля p.norm, то есть 5
|
||||
z = 1; // Поле z осталось видимым
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue