C++ examples for Statement:throw
Throwing the Result of a Conditional Expression
#include <iostream> #include <stdexcept> int main(int argc, const char *argv[]) { try {// ww w . ja va2s . c o m int i = 6; double d = 6.5; false ? throw i : throw d; // double should throw } catch (int i) { std::cout << "i was thrown" << std::endl; } catch (double d) { std::cout << "d was thrown" << std::endl; } return 0; }