Skip to content

Instantly share code, notes, and snippets.

@weshouman
Last active June 23, 2016 04:19
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 weshouman/e7ec935418b4e9bd7d8d5ca0728c7540 to your computer and use it in GitHub Desktop.
Save weshouman/e7ec935418b4e9bd7d8d5ca0728c7540 to your computer and use it in GitHub Desktop.
sparse materials, for curious ppl and interview seekers

#how do we know object type in runtime :? that could be if: the language support RTTI

##type introspection figuring the metadata at runtime
https://en.wikipedia.org/wiki/Type_introspection

##C++ specific ###dynamic_cast way: Dynamic cast an object to a class, do we get a bad_cast exception, then it's not the right type
be cautious base class must have at least one virtual method!!
http://stackoverflow.com/a/351865/2730737 ###type_id way:

#include <typeinfo>
string s = typeid(YourClass).name()

http://stackoverflow.com/a/4325139/2730737

##type reflection manipulating the metadata at runtime
https://en.wikipedia.org/wiki/Type_reflection

the word binding!

types, functions and values determination at run/compile time (dynamic loading, dispatching and binding)
http://programmers.stackexchange.com/questions/200115/what-is-early-and-late-binding/200123#200123

the four types of polymors

Subtype polymorphism (runtime polymorphism).
Parametric polymorphism (compile-time polymorphism).
Ad-hoc polymorphism (overloading).
Coercion (implicit or explicit casting).

http://www.catonmat.net/blog/cpp-polymorphism/

scope resolution operator ::

use to force traversing from the global namespace downword while figuring out which class to use
http://stackoverflow.com/a/4269064/2730737

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment