OK, mistake in what a shared pointer does.
A Shared pointer takes full ownership of a pointer. When that pointer goes out of scope, it'll delete that pointer.
You are inializsing the nodes as an node [8][]
. Your pointer is an address in this 2D array! When you need to call delete (which'll get called when your shared_ptr goes out of scope i.e. whenever you remove elements from the vector), you are essentially calling delete nodes[i][j]
, which you'd expect to barf.
Just use references in this case (Node&), which will be perfectly valid and work just fine.