In your main you define gh(5)
which allocates the vector of size 5 then you use your addEdge
method with parameter (5,6)
which tries to access list[5]
but the five list entries are list[0],list[1],list[2],list[3],
and list[4]
. So I guess gh.addEdge(5,6)
gives the Segmentation fault as it is out of range of your vector.
0
solved c++ error : Segmentation fault (core dumped)