#include <iostream>
#include <vector>
using namespace std;
struct Character {
virtual void action() = 0;
};
struct Warrior : public Character {
void action() { cout << "Warrior attacks with a sword!" << endl; }
};
struct Mage : public Character {
void action() { cout << "Mage casts a fireball!" << endl; }
};
int main() {
Warrior w;
w.action();
Mage m;
m.action();
vector<Character*> characters = { &w, &m };
for (auto c : characters) {
c->action();
}
}