Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include "ConsoleApplication1.h"
- #include <vector>
- #include <algorithm>
- #include <functional>
- #include <string>
- using namespace std;
- int main()
- {
- vector<int> ;
- vector<string>::iterator myIterator; //identify a particular element in a container //Here you can change the item it gets
- vector<string>::const_iterator iter; //Here is a ready only iterator you cant modify the item he gets
- vector<string> inventory;
- inventory.push_back("Sword");
- inventory.push_back("Shit");
- inventory.push_back("Pombo");
- //cout << inventory.size();
- //for (int i = 0; i < inventory.size(); i++) {
- // cout << inventory[i] << "\n";
- //}
- //inventory[2] = "POMBAO";
- //for (int i = 0; i < inventory.size(); i++) {
- // cout << inventory[i] << "\n";
- //}
- //inventory.pop_back(); //Remove the last item on inventory
- //for (int i = 0; i < inventory.size(); i++) {
- // cout << inventory[i] << "\n";
- //}
- //inventory.clear() // Remove everything
- //Looping through a Vector with iterator
- //print the size:
- //(*iter).size()
- //
- myIterator = inventory.begin(); //set myIterator to reference the first element of inventory
- *myIterator = "battle axe"; //change the value of the first element
- cout << myIterator->size() << " letters in it.\n";
- inventory.insert(inventory.begin(), "crossbow");
- inventory.erase((inventory.begin() + 2)); //Remove
- for (iter = inventory.begin(); iter != inventory.end();
- ++iter)
- cout << (*iter).size() << endl;
- return 0;
- }
- //Dont shoot hes not b
- //https ://www.youtube.com/watch?v=GDYJO-1IhN8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement