I get a CXX0030 run-time error (Microsoft Visual Studio 2008, C++) off executing the outputShortestPath method of the ShortestPath (derived from Graph) class, that call is in main.cpp on line 290. The method outputShortestPath calls the function getPrior of the Vertex class, shortestpath.h on line 156, now the problem here seems to be when the operator= overload executes for the Vertex class (graph.h line 577) , getPrior accesses a pointer call prior that points to a different Vertex. Prior needs to be dereferenced and assigned to the Vertex<type>&. Inside the operaotr=, there is access issues, but if I switch out that 'rightVertex.protectedMember' for a function 'rightVertex.getProtectedMember()', then the problem dives further, and in the accessor (isSource() graph.h, line 506), that has one line, and just returns the protected member, that one line is the break point for CXX0030 i've traced down to, Error: expression cannot be evaluated.
Anyone very skilled with MS VS 2008 debugger can probably identify this, or someone who has seen this before. I understand the files I've attached have a few lines of code in them, but I've tried to nail the issue down above.
good night!, simply making a temp bool, and copying the data member 'source' to it, and them returning the temp instead of the data member fixes that problem.
Why is that? (C++ has managed to piss me off with ridiculous requirements and particularities regarding OOP than any other language, I personally feel that its no good for OOP, Java is a much better choice, C# even better than Java. C++ needs to stay closer to the hardware, but this course has alot of OOP for using C++)
(Now I have to go through and change every line for the overload, and add accessor functions for any data I wanted to copy in the assignment)
Error 1 error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const Vertex<type>' (or there is no acceptable conversion) c:\program files\microsoft visual studio 9.0\vc\include\xutility 3133 296a8
After I made the changes necessary (first comment), I get the above error. I went back and changed what you mentioned to not dereference a NULL pointer. I do not even know what xutility is
Updated files, the problem is with the operator= and copy constructor for Vertex<type> (in graph.h). They both assign "this" 's source (bool data member) the return of the other Vertex<type>'s isSource() function. When the program does into isSource() for that 'right' Vertex, is cannot seem to access the data member source, return it, or even assign it to a temporary and return that.
If you change the file extentions to .h for the headers and .cpp for main, you can create a win32 console app in visual studio and run the debugger to see what is going on.
I realize this question isn't as nice as those 'how do I reverse a string' or 'how do I convert characters to integers ASCII' 500 point questions. If the logic is damaged (which it most likely is), thats one thing, and comes after I can it passed compiling and debugging. If I could have this question worth more, I'd put it at or above 1,000 in a heartbeat.
The overload for comparisons within priority_queue was incorrect. I am beginning to think I may have a small memory leak associated with the strings contained in my type being stored in the Graph (City, has a string for name).
The issue lies in the re-heap algorithm, and my use of pointers with priority_queue, and then the algorithm gets applied to them. Maybe I'm missing an overload I should have, but this problem really requires a different approach, a different language (C#, better OOP support), and to strip out the STL classes, and make my own implementations that are worth debugging. That is probably the most important, making my own classes in place of the STL's messy debauchery of C, abstract classes/inheritance/etc., wrappers, and generic algorithms.