I want to pass to a function a std::vector but i wont want to copy the whole vector. I just want to pass the adress to the vector. So i try to use a pointer and i find out that i cant use the brackets to acces which element from the vector i want. How do i do that? This come gives me the error "
cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'
"
#include <iostream>
#include <vector>
using namespace std;
void f(vector<int>* x);
int main()
{
vector<int>a;
a.push_back(1);
a.push_back(2);
a.push_back(3);
a.push_back(4);
a.push_back(5);
f(&a);
return 0;
}
void f(vector<int>* x)
{
int i;
for(i=0;i<x->size();i++)
cout<<x[i];
}