Advertisement
BHXSpecter

Struct/Vector Experiment

Apr 25th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. struct Weapons{
  8.     string name;
  9.     int atk;
  10.     int price;
  11. };
  12.  
  13. /*struct Armors{
  14.     string name;
  15.     int def;
  16.     int price;
  17. };
  18.  
  19. struct Enemies{
  20.     string name;
  21.     int atk;
  22.     int health;
  23.     int def;
  24. };*/
  25.  
  26. int main()
  27. {
  28.     vector<Weapons> swords;
  29.     vector<Weapons> axes;
  30.     vector<Weapons> staffs;
  31.    
  32.     swords.push_back(Weapons());
  33.     swords.push_back(Weapons());
  34.    
  35.     swords[0].name = "Bastard Sword";
  36.     swords[0].atk = 26;
  37.     swords[0].price = 35;
  38.    
  39.     swords[1].name = "Broad Sword";
  40.     swords[1].atk = 32;
  41.     swords[1].price = 50;
  42.    
  43.     for (int i = 0; i < 2; i++)
  44.     {
  45.         cout << swords[i].name << ' ' << swords[i].atk << ' ' << swords[i].price << endl;
  46.     }
  47.    
  48.        
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement