Skip to content

Instantly share code, notes, and snippets.

@meshell
Created February 22, 2016 21:24
Show Gist options
  • Save meshell/8be77e377f84c3333dcd to your computer and use it in GitHub Desktop.
Save meshell/8be77e377f84c3333dcd to your computer and use it in GitHub Desktop.
struct base {
virtual std::string name() { return "default"; }
virtual void foo() final { }
};
struct derived final: public base {
std::string name() override { return "derived!" }
// compile error: overriding final function 'virtual void base::foo()'
void foo() override { }
};
// compile error: cannot derive from 'final' base 'derived'
struct further_derived : public derived {
std::string name() override { return "further derived!" }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment