RosettaCodeData/Task/Respond-to-an-unknown-method-call/C++/respond-to-an-unknown-method-call.cpp

18 lines
266 B
C++
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
class animal {
public:
virtual void bark() // concrete virtual, not pure
{
throw "implement me: do not know how to bark";
}
};
class elephant : public animal // does not implement bark()
{
};
int main()
{
elephant e;
e.bark(); // throws exception
}