Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include "character.h"
- #include "knight.h"
- #include "rat.h"
- using namespace std;
- void print(std::vector <Character*> chars){
- for (auto it = chars.begin() ; it != chars.end(); ++it){
- Character *ch = (*it);
- cout << ch->getName () << endl;
- }
- }
- int main()
- {
- cout << "Hello World!" << endl;
- std::vector <Character*> chars;
- Character *knight = new Knight("Knight");
- Character *rat = new Rat("Rat");
- chars.push_back(knight);
- chars.push_back(rat);
- cout << "Size: " << chars.size () << endl;
- print(chars);
- cout << endl;
- while(1){
- chars.erase (chars.begin ()+1);
- cout << "Size: " << chars.size () << endl;
- print(chars);
- }
- delete knight;
- delete rat;
- knight = NULL;
- rat = NULL;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement