Demonstrates passing constant pointers to constant objects : constant « Data Type « C++






Demonstrates passing constant pointers to constant objects

  
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void display(const vector<string>* const pInventory);

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>* const pInventory)
{
    for (vector<string>::const_iterator iter = (*pInventory).begin(); 
         iter != (*pInventory).end(); ++iter)
         cout << *iter << endl;
}
  
    
  








Related examples in the same category

1.Demonstrates constants