Vector Initialisation in C++
问题 I am using Vectors in my code. The line that is causing the error is as follows : vector<Node> alt_seq ; alt_seq = vector<Node>(1000); for(int j=0; j<alt_cf.getNoOfNodes(i); j++) { Node temp_node = *alt_itr; alt_itr++; alt_seq.push_back(temp_node); } The line : alt_seq.push_back(temp_node); causes a runtime error. However if I initialise the Vector with some initial size as follows: vector<Node> alt_seq(1000) ; In this case the code works fine. However I do not want to give an initial size as