Pointing to vectors
- by Matt Munson
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
vector <int> qwerty;
qwerty.push_back(5);
vector <int>* p = &qwerty;
cout << p[0]; //error: no match for 'operator<<' in 'std::cout << * p'
}
I'm generally unclear on how to use pointers with vectors, so I'm pretty mystified as to why this is not working. To my mind, this should print 5 to screen.