module pind.samples.ja.special_functions.special_functions_5; import std.stdio; struct Student { const char[] fileName; int[] grades; this(const char[] fileName) { this.fileName = fileName; } void save() { auto file = File(fileName.idup, "w"); file.writeln("The grades of the student:"); file.writeln(grades); } // ... } void main() { char[] fileName; fileName ~= "student_grades"; auto student = Student(fileName); // ... /* ファイル名変数(fileName)が後で意図せず * 変更された場合(ここではすべての文字が * 'A'に設定されている): */ fileName[] = 'A'; // ... /* 成績が間違ったファイルに書き込まれる: */ student.save(); }