constant references
#include <iostream> #include <string> #include <vector> using namespace std; //a constant reference to a vector of strings void display(const vector<string>& v); int main() { vector<string> v; v.push_back("A"); v.push_back("B"); v.push_back("C"); display(v); return 0; } void display(const vector<string>& vec) { for (vector<string>::const_iterator iter = vec.begin(); iter != vec.end(); ++iter) cout << *iter << endl; }