4 глава

This commit is contained in:
Alexander Zhirov 2023-02-05 19:45:16 +03:00
parent e0caa7caab
commit ec805e7f08
15 changed files with 1584 additions and 1 deletions

View file

@ -0,0 +1,29 @@
/**
* 1. Объявите класс, который наследуется от Exception.
* 2. Создайте конструктор, который принимает, как минимум, два параметра: string file и
* size_t line, со значениями по умолчанию __FILE__ и __LINE__ соответственно.
* 3. Попросите конструктора переслать аргументы конструктору исключения (super).
* 4. Используйте свое исключение.
*/
class MyException : Exception
{
this (string message, string file = __FILE__, size_t line = __LINE__, Throwable next = null)
{
super(message, file, line, next);
}
}
void main()
{
import std.stdio;
try
{
throw new MyException("message here");
}
catch(MyException e)
{
writeln("caught ", e);
}
}