Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
kelas
Kelas ini berfungsi sebagai kelas dasar untuk semua pengecualian yang dilemparkan untuk melaporkan kesalahan yang mungkin dapat dideteksi sebelum program dijalankan, seperti pelanggaran prasyarat logis.
Sintaks
class logic_error : public exception {
public:
explicit logic_error(const string& message);
explicit logic_error(const char *message);
};
Keterangan
Nilai yang dikembalikan oleh what() adalah salinan .message.data() Untuk informasi lebih lanjut, lihat what dan data.
Contoh
// logic_error.cpp
// compile with: /EHsc
#include <exception>
#include <iostream>
#include <stdexcept>
#include <typeinfo>
using namespace std;
int main()
{
try
{
throw logic_error("Does not compute!");
}
catch (const exception& e)
{
cerr << "Caught: " << e.what() << endl;
cerr << "Type: " << typeid(e).name() << endl;
}
}
Caught: Does not compute!
Type: class std::logic_error
Persyaratan
Header:<stdexcept>
kumpulan nama XML: std