Vector Initialisation in C++

前端 未结 2 1231
无人及你
无人及你 2021-01-25 20:26

I am using Vectors in my code.

The line that is causing the error is as follows :

vector alt_seq ;
alt_seq = vector(1000);
for(in         


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-25 20:39

    I can see one problem; when you declare 1000 vector objects and then do a push_back you're adding to the end of the vector, i.e. the objects that you're trying to add are at 1001, 1002.... etc. If declaring 1000 vector objects doesn't give you a runtime error, I would first see what's the default definition (since the first 1000 node objects have default values), since that's not error out and compare against the actual data I'm trying to load. Hope this helps.

提交回复
热议问题