Skip to content

Instantly share code, notes, and snippets.

@xr1s
Last active March 1, 2023 18:26
Show Gist options
  • Save xr1s/80788078b65adb0d5ee4ff5ba916fa91 to your computer and use it in GitHub Desktop.
Save xr1s/80788078b65adb0d5ee4ff5ba916fa91 to your computer and use it in GitHub Desktop.
#include <stdio.h>
struct Basest {
virtual void foo() {
return this->bar();
}
virtual void bar() = 0;
};
struct Mother: virtual Basest {
virtual void bar() override {
puts("Mother");
}
};
struct Father: virtual Basest {
virtual void foo() override {
puts("Father");
this->bar();
}
};
struct Derivest
: virtual Mother
, virtual Father {};
int main() {
Basest *p = new Derivest;
p->foo();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment