Created
March 13, 2013 03:22
-
-
Save kdmkdmkdm/5149148 to your computer and use it in GitHub Desktop.
star 37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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