Skip to content

Instantly share code, notes, and snippets.

@kdmkdmkdm
Created March 13, 2013 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdmkdmkdm/5149148 to your computer and use it in GitHub Desktop.
Save kdmkdmkdm/5149148 to your computer and use it in GitHub Desktop.
star 37
// invetoryDisplayer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
// Inventory Displayer
// Demonstrates constant references
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// parameter vec is a constant reference to a vector of strings
void display(const vector<string>& inventory);
int main()
{
vector<string> inventory;
inventory.push_back("sword");
inventory.push_back("armor");
inventory.push_back("sheild");
display(inventory);
return 0;
}
// parameter vec is a constant reference to a vector of strings
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment