void display(const vector<string>& vec); //prototype
int main()
{
vector<string> inventory;
inventory.push_back("Obj1");
inventory.push_back("Obj2"); //load the vector
inventory.push_back("Obj3");
display(inventory);
cin.get();
return 0;
}
void display(const vector<string>& vec)
{
vector<string>::const_iterator iter; //iterator to go through the loop
cout<<"Your items\n ";
for(iter = vec.begin();iter != vec.end();++iter) //display the contents of the vector
cout << *iter << endl;
}
Hey guys,
I'm looking into pointers in functions, and in this part of the program there is an "&" sign. Ive known these to be "An address of" and the program runs with our without them, I'm just wondering what exactly are they doing?