Created
November 13, 2023 07:59
-
-
Save zakki/311c35bd3346dc35804458c3685aa3fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <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