I'm fairly new to C++ especially STL. I'm trying to pass a vector as argument to a function, but it causes the application to crash. I'm using Code::Blocks and MingW. Here is a simple code.
#include <iostream>
#include <vector>
using namespace std;
void foo(const vector<int> &v)
{
cout << v[0];
}
int main(){
vector<int> v;
v[0] = 25;
foo(v);
return 0;
}
Thanks!