Last active
March 1, 2023 18:26
-
-
Save xr1s/80788078b65adb0d5ee4ff5ba916fa91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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