Created
March 5, 2016 20:03
-
-
Save montreal91/48df64f838c5d202e915 to your computer and use it in GitHub Desktop.
Evil inheritance
This file contains 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 <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