Skip to content

Instantly share code, notes, and snippets.

@edvakf
Created April 4, 2011 14:07
Show Gist options
  • Select an option

  • Save edvakf/901682 to your computer and use it in GitHub Desktop.

Select an option

Save edvakf/901682 to your computer and use it in GitHub Desktop.
#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;
}
> 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