Skip to content

Instantly share code, notes, and snippets.

@Joshhua5
Created June 7, 2014 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Joshhua5/33ec4432bf9c04c64715 to your computer and use it in GitHub Desktop.
Save Joshhua5/33ec4432bf9c04c64715 to your computer and use it in GitHub Desktop.
struct A{
int get(){ return 1; }
};
struct B : public A{
int get(){ return 2; }
};
struct D {
int get(){ return 3; }
};
struct C : public B, public D{
int get(){ return 4; }
};
int main(){
C c;
int
i = dynamic_cast<A*>(&c)->get();
i += dynamic_cast<B*>(&c)->get();
i += dynamic_cast<D*>(&c)->get();
i += dynamic_cast<C*>(&c)->get();
return i;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment