-
-
Save edvakf/901682 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 <stdio.h> | |
| class Base { | |
| }; | |
| class Derived : Base { | |
| public: | |
| void say() { | |
| printf("Derived"); | |
| } | |
| }; | |
| int main() { | |
| Base *b = new Base(); | |
| Derived *d = static_cast<Derived *>(b); | |
| d->say(); | |
| return 0; | |
| } | |
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
| > cl a.cc | |
| Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86 | |
| Copyright (C) Microsoft Corporation. All rights reserved. | |
| a.cc | |
| Microsoft (R) Incremental Linker Version 10.00.30319.01 | |
| Copyright (C) Microsoft Corporation. All rights reserved. | |
| /out:a.exe | |
| a.obj | |
| > ./a.exe | |
| Derived |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment