I have a small program that compiles and runs, but after execution, Visual Studio is giving me the following error message:
Windows has triggered a breakpoint in LAN.exe. This may be due to a corruption of the heap, which indicates a bug in LAN.exe or any of the DLLs it has loaded.
I noticed that if I comment out the second to last line in Network::add then I don't get the error, which suggests that I am assigning the Node to the Node* incorrectly. However, it compiles and outputs correctly to the console. As you can see from Main.cpp, only the Network constructor, Network::add, and the Node constructor are actually called. I would very much appreciate it if anyone can see what the problem is. :D
In the Network() destructor, you're trying to delete a stack variable - since you didn't allocate it with new, delete won't work on that address. That's why it says there's a corruption of the heap - it's not on the heap to start with.