CJCoding With Joseph
15free / daySign inCreate account
← Back to Question List

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics:
C++ Quiz #149

Inheriting runtime_error's Constructor

mediumExceptions

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>
4 
5class ConfigError : public std::runtime_error {
6public:
7 using std::runtime_error::runtime_error;
8};
9 
10int 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}