module pind.samples.ja.interface.interface_2; import std.stdio; struct Point { size_t id; // オブジェクトID int line; int column; // 次のオブジェクトに使用するID static size_t nextId; this(int line, int column) { this.line = line; this.column = column; this.id = makeNewId(); } static size_t makeNewId() { immutable newId = nextId; ++nextId; return newId; } } void main() { auto top = Point(7, 0); auto middle = Point(8, 0); auto bottom = Point(9, 0); writeln(top.id); writeln(middle.id); writeln(bottom.id); }