RosettaCodeData/Task/Respond-to-an-unknown-method-call/C++/respond-to-an-unknown-method-call.cpp
2023-07-01 13:44:08 -04:00

17 lines
266 B
C++

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
}