First off, I'd like to point out I am new to the forums here so if you must bash my ignorance, please do so gently.
This question is related to a problem I'm having with my assignment. I kind of don't want to post code because I don't want someone to fix my code for me -- instead I have a question that might help me understand whats going on. Basically, I'm reading information from a text file and using that info as arguments for creating a new class instance to push_back into a list. My code worked when I used a vector and with a DList (an example doubly linked list created by my instructor). But as soon as I switched to a list, push_back fails and my code breaks because I attempt to change a garbage value later in the code.
So my question is: is there something different about the push_back function between vector and list that would prevent it from pushing a class object?
Seeing the code will help in diagnosing the problem, but if you're uncomfortable with that, you could just give us an example of the issue.
And what is the exact error you are getting?
Right now it breaks at the call to SetName() because the invoking object doesn't exist and I get an error saying something along the lines of "attempted to read or write into protected memory".
"C++/CLI" is Microsoft's convoluted version of C++. I'm really glad you're not using it ;)
So I have to wonder: (*foo.begin() + 1)->SetName(RandomName());
This makes me think that whatever (*foo.begin()) returns is a pointer, then you add one to it, then you call the function on it.
maybe you meant: (*(foo.begin() + 1))->SetName(RandomName());