Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Simple enemy polimorphism
#include <iostream> #include <vector> struct Enemy { std::string Name="---"; int HP=0; void Draw() { std::cout<<Name<<" HP: "<<'\n'; } }; struct FireGolem : Enemy { FireGolem() { Name="Fire golem"; HP=100; } }; struct Wolf : Enemy { Wolf() { Name="Wolf"; HP=30; } }; struct Dragon : Enemy { Dragon() { Name="Dragon"; HP=500; } }; int main() { std::vector<Enemy*> Vec; Vec.push_back(new Wolf); Vec.push_back(new FireGolem); Vec.push_back(new Dragon); for(auto i:Vec) { i->Draw(); } }
run
|
edit
|
history
|
help
0
NonparaU
POI
float precision test
Menu Combination Sum
code_chef
process memory structure
Boost phoenix. e.g 3 phoenix: functor
ListTel
ONP
HelloWorld