Code:
typedef std::vector<unsigned int> VecUnsRAM;
VecUnsRAM myPos(vertices.size());
unsigned int count=0;
for(unsigned int j=0; j<vertices.size();++j) {
myP t=std::make_pair(count, vertices[j].D);
std::cout<<"Got here"<<std::endl;
PQ[j]=t;
std::cout<<"Got here"<<std::endl;
myPos[j]=count;// or myPos[j]=j; produces Seg fault error
std::cout<<"Got here"<<std::endl;
++count;
}
typedef std::vector<unsigned int> VecUnsRAM;
VecUnsRAM myPos(vertices.size());
unsigned int count=0;
for(unsigned int j=0; j<vertices.size();++j) {
myP t=std::make_pair(count, vertices[j].D);
std::cout<<"Got here"<<std::endl;
PQ[j]=t;
std::cout<<"Got here"<<std::endl;
myPos[j]=count;// or myPos[j]=j; produces Seg fault error
std::cout<<"Got here"<<std::endl;
++count;
}
The output is "Got here" twice, and then the Seg fault. Any ideas why this happens?
Thanks