Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. #include "character.h"
  5. #include "knight.h"
  6. #include "rat.h"
  7. using namespace std;
  8.  
  9. void print(std::vector <Character*> chars){
  10.     for (auto it = chars.begin() ; it != chars.end(); ++it){
  11.  
  12.         Character *ch =  (*it);
  13.         cout << ch->getName () << endl;
  14.     }
  15. }
  16.  
  17. int main()
  18. {
  19.     cout << "Hello World!" << endl;
  20.     std::vector <Character*> chars;
  21.  
  22.     Character *knight = new Knight("Knight");
  23.     Character *rat = new Rat("Rat");
  24.  
  25.     chars.push_back(knight);
  26.     chars.push_back(rat);
  27.     cout << "Size: " << chars.size () << endl;
  28.  
  29.     print(chars);
  30.  
  31.     cout << endl;
  32.     while(1){
  33.         chars.erase (chars.begin ()+1);
  34.         cout << "Size: " << chars.size () << endl;
  35.         print(chars);
  36.     }
  37.     delete knight;
  38.     delete rat;
  39.     knight = NULL;
  40.     rat = NULL;
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement