← Back to Question List
C++ Quiz #139
The Type of a Thrown String Literal
throw "disk full"; throws a string literal. Which handler runs?
📄 Code
1#include <iostream>2#include <string>34int main() {5 try {6 throw "disk full";7 } catch (const char* message) {8 std::cout << "text: " << message << "\n";9 } catch (const std::string& message) {10 std::cout << "string: " << message << "\n";11 }12 return 0;13}