exception& exception::operator=(const exception& kqrException);
#include <exception>
#include <iostream>
#include <exception>
void ThrowException() throw(std::exception) {
throw std::exception();
}
int main() {
using namespace std;
// The try-catch block allows us to handle exceptions
try {
// Call a function to throw an exception
ThrowException();
} catch(const exception& kqrException) {
// Make an initial assignment
exception qMyExcept = kqrException;
cerr << "Message: " << qMyExcept.what() << endl;
cerr << "Type: " << typeid(qMyExcept).name() << endl;
// Set it equal to a bad_exception
qMyExcept = bad_exception();
cerr << "Message: " << qMyExcept.what() << endl;
cerr << "Type: " << typeid(qMyExcept).name() << endl;
}
// Keep the window open
std::cin.get();
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.