Skip to content

Instantly share code, notes, and snippets.

@montreal91
Created March 5, 2016 20:03
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 montreal91/48df64f838c5d202e915 to your computer and use it in GitHub Desktop.
Save montreal91/48df64f838c5d202e915 to your computer and use it in GitHub Desktop.
Evil inheritance
#include <iostream>
template<typename T>
class EvilClass {
public:
virtual void DoSomething( T param ) {
std::cout << "I've done something\n";
}
};
typedef EvilClass<int> EvilInt;
class EvilFloat : public EvilInt {
public:
virtual void DoSomething( double param ) {
for ( int i = 0; i < param; i++ ) {
std::cout << "Int " << i << std::endl;
}
}
};
int main( int argc, char const *argv[] ) {
EvilFloat f;
f.DoSomething( 3 );
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment