std::bad_alloc
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>| Elemento definito nell'header <new>
|
||
class bad_alloc; |
||
std::bad_alloc is the type of the object thrown as exceptions by the
to report failure to allocate storage.
Inheritance diagram
Membri funzioni
| constructs the bad_alloc object (metodo pubblico) | |
| replaces a bad_alloc object (metodo pubblico) | |
restituisce stringa esplicativa Original: returns explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
Inherited from std::exception
Member functions
[virtuale] |
distrugge l'oggetto eccezione Original: destructs the exception object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico virtuale) |
[virtuale] |
restituisce una stringa esplicativa Original: returns an explanatory string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico virtuale) |
Esempio
#include <iostream>
#include <new>
int main()
{
try {
while (true) {
new int[100000000ul];
}
} catch (const std::bad_alloc& e) {
std::cout << "Allocation failed: " << e.what() << '\n';
}
}
Output:
Allocation failed: std::bad_alloc
Vedi anche
allocazione funzioni Original: allocation functions The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione) | |