Newsgroup: comp.lang.c++
Subject: vector
From: Rosario1903 <Rosario@...>
Date: Thu, 28 Nov 2013 10:59:07 +0100
why the below goes to seg fault?
#include <iostream>
#include <vector>
using namespace std;
void f(vector<unsigned>& v)
{v[3]=4; v[4]=9;}
int main(void)
{vector <unsigned> mv;
mv[0]=1; mv[1]=2;
f(mv);
cout<<"mv[0]="<<mv[0]<<", mv[1]="<<mv[1]<<"\n";
cout<<"mv[3]="<<mv[3]<<", mv[4]="<<mv[4]<<" mv[5]="<<mv[5]<<"\n";
return 0;
}
Subject: vector
From: Rosario1903 <Rosario@...>
Date: Thu, 28 Nov 2013 10:59:07 +0100
why the below goes to seg fault?
#include <iostream>
#include <vector>
using namespace std;
void f(vector<unsigned>& v)
{v[3]=4; v[4]=9;}
int main(void)
{vector <unsigned> mv;
mv[0]=1; mv[1]=2;
f(mv);
cout<<"mv[0]="<<mv[0]<<", mv[1]="<<mv[1]<<"\n";
cout<<"mv[3]="<<mv[3]<<", mv[4]="<<mv[4]<<" mv[5]="<<mv[5]<<"\n";
return 0;
}
via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?138316-vector&goto=newpost
View all the progranning help forums at:
http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums
No comments:
Post a Comment