mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-12-03 00:07:21 +00:00
9 lines
495 B
C++
9 lines
495 B
C++
struct Base { virtual int calculate() { return 1; } };
|
|
struct Child : Base { int calculate() override { return 2; } };
|
|
struct Grandchild : Child { int calculate() override { return 3; } };
|
|
struct Other { int compute() { return 4; } };
|
|
int dispatch(Base& base, Child& child, Grandchild& grandchild, Other& other) {
|
|
return base.calculate() + child.calculate() + grandchild.calculate() + other.compute();
|
|
}
|
|
const char *label = "compute";
|
|
// compute on Other is unrelated to the virtual family.
|