2. 3. , 2. (== ) (== call). , (. ). 2. , std::runtime_error::what, "user_error", , :
[runtime.error]
runtime_error(const char* what_arg);
4 : runtime_error.
5 : strcmp(what(), what_arg) == 0.
, .
[class.virtual]
15 scope (5.1) .
3. . using , , .
, user_error::what std::runtime_error::what. user_error::what std::exception::what.
, , std::exception::what ? ( ):
[]
7 : NTBS, . ( )
, - , , , , . .
, :
#include <iostream>
struct A {
virtual void x() {
std::cout << "A\n";
}
};
struct B : A {
void x() {
std::cout << "B\n";
}
};
struct C : B {
using A::x;
};
int main() {
C c;
c.x();
c.C::x();
return 0;
}
.