← Back to Question List
C++ Quiz #149
Inheriting runtime_error's Constructor
ConfigError declares no constructor of its own, only a using-declaration. What does throw ConfigError("missing key: port") do?
📄 Code
1#include <iostream>2#include <stdexcept>3#include <string>45class ConfigError : public std::runtime_error {6public:7 using std::runtime_error::runtime_error;8};910int main() {11 try {12 throw ConfigError("missing key: port");13 } catch (const ConfigError& e) {14 std::cout << "config problem: " << e.what() << "\n";15 }16 return 0;17}