Меню Закрыть

Std out of range

Содержание

Этот класс служит базовым для всех исключений, создаваемых для сообщения о том, что аргумент выходит за допустимый диапазон. The class serves as the base class for all exceptions thrown to report an argument that is out of its valid range.

Синтаксис Syntax

Примечания Remarks

Значение, возвращаемое what, — это копия данных . сообщения. The value returned by what is a copy of message . data.

Пример Example

Вывод Output

Требования Requirements

Заголовок: Header:

Пространство имен: std Namespace: std

I have the following code below:

So if i have an array with values

should throw an exception "OUT OF RANGE" but it spits out the value 0. I’m not sure what’s going on.

1 Answer 1

My guess is that data[index] doesn’t throw exception if the index goes out of range because it is not supported by the type of data . What is the type of data ? Is it an array like X data[N] ?

If so, then do the check yourself:

Note that _size is assumed to be size of the so-called container data .

This class defines the type of objects thrown as exceptions to report an out-of-range error.

It is a standard exception that can be thrown by programs. Some components of the standard library, such as vector , deque , string and bitset also throw exceptions of this type to signal arguments out of range.

Читайте также:  Nobby comfort 6000mah black

Рекомендуем к прочтению

Добавить комментарий

Ваш адрес email не будет опубликован.