Skip to content

Instantly share code, notes, and snippets.

@zakki
Created November 13, 2023 07:59
Show Gist options
  • Save zakki/311c35bd3346dc35804458c3685aa3fb to your computer and use it in GitHub Desktop.
Save zakki/311c35bd3346dc35804458c3685aa3fb to your computer and use it in GitHub Desktop.
#include <iostream>
class A {
public:
virtual int foo() = 0;
};
class B : public A {
public:
virtual int foo() override {
return 10;
}
};
int main() {
B* b = new B();
A& ra = *b;
std::cout << ra.foo();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment