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
string probe
Policy based smart pointer
Laborator 2 SD
generate BinTree from sorted list
MyStack
Dar
const_cast
epsilon
ulib
sort