So this code doesn't print out the entries inside of the vector gameLibrary
Originally I just used the gameLibrary.pushback(" ") function to add them and that worked fine.
I'm more just trying to get to grips with why this doesn't work. when ( at least in my mind it's doing the same thing)
#include <iostream>
#include <vector>
#include <string>
using std::cout;
using std::vector;
using std::string;
void addGame(vector<string> gameLibrary, string gameName);
int main()
{
vector<string> gameLibrary;
vector<string>::iterator editIter;
addGame(gameLibrary, "game");
addGame(gameLibrary, "game 2");
cout << "Your library: " << std::endl;
for (editIter = gameLibrary.begin(); editIter != gameLibrary.end(); ++editIter)
{
cout << *editIter << std::endl;
}
return 0;
}
void addGame(vector<string>gameLibrary, string gameName)
{
gameLibrary.emplace_back(gameName);
}