Pointing to vectors

Posted by Matt Munson on Stack Overflow See other posts from Stack Overflow or by Matt Munson
Published on 2011-01-17T02:07:42Z Indexed on 2011/01/17 5:53 UTC
Read the original article Hit count: 267

Filed under:
|
|
#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.

© Stack Overflow or respective owner

Related posts about c++

Related posts about pointers