Vector Initialisation in C++

前端 未结 2 1226
无人及你
无人及你 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:42

    Your Node class has a pointer member of type CombinedFragment* called cfrag. This creates dangling references if you don't defined your own copy ctor and assignment operators. Further, a proper dtor is required to prevent leaks if Node is responsible for allocating/deallocating cfrag. If you don't want to deep-copy CombinedFragment you can use a shared_ptr.

    Also, the default ctor for Node probably doesn't even need to be there (it leaves cfrag to an uninitialized state).

提交回复
热议问题