More questions from a newbie
I am going through a book Learn c++ through game programming. I am on chapter 6 which is using references. Can someone help me understand what is going on in this code? https://code.sololearn.com/c7W8kffkVuXD/#cpp. Let me try to show what I think I understand. void display(cons vector<string>& inventory); So I believe that this is a function ? I dont understand what is going on inside (). Its even more confusion when you look at the definition of the function void display(const vector<string>& vec) { cout<<"Your items: \n"; for(vector<string>::const_iterator iter= vec.begin(); iter!=vec.end();++iter) { cout<<*iter<<endl; } } Im so confused by it I dont even know what questions to ask please help. I "THINK" that void display(const vactor<string>& vec) is creating a reference that references inventory and names it vec so vec is a vector of strings that are = vector<string> inventory. what is also confusing me is why in the top void display it says void display(const vector<string>& inventory) and why is there an & there. I think what is really throwing me is how in the function prototype it says void display(const vector<string>& inventory) but in the definiton of the function it is void display(const vector<string>& vec) I dont understand how the definition can differ from the prototype and still work.