
please wait
|
|
Dagron Boom;
set the parameter of Boom inside the wile loop. So then I was trying to figure out a way to store these objects, and I thought I could store them in a map with a string as their key and the object as the mapped value...but I guess that doesn't work? I'm not really sure. |
|
|
|
|
Dagron Rawr("Rawr", etc, etc)
but how would my program know to use Rawr as the name of the object?map<string, Character> characterMap
? Because I tried to do that before and it didn't work. Though maybe it will now using the pair.make_pair()
instead of just pair<>
and now I can successfully create a map of as many different pointers to characters as I want. However....map<string, Character*>
so that the program can store pointers to derived classes of Character in the map.gameDriver.cpp(76) : error C2039: 'rescue' : is not a member of 'Character' c:\programming\Character.h(24) : see declaration of 'Character' |
I want the map to store Dagron objects And Tyrant objects, |
|
|
mapIter->second->displayStatistics();
I get a segmentation fault when using g++ in xcode. I have literally been searching Google for the past two hours trying to figure out how the hell to use the iterator to the pointer in my map so that I can access the functions of the object the pointer points to, but EVERYTHING I've tried has either not compiled or given a segmentation fault once I get to that part of the program. I read somewhere that because it's an iterator to a pointer, you simply can't use the -> to access the map value (the pointer), but I don't understand what else I'm supposed to do....someone PLEASE help. I'd prefer not to fail this class at the very end of the semester.
mapIter->second->displayStatistics(); |
|
|
new
transfering the ownership to the container.delete
or use an smart pointer
new
and delete
in my code properly?delete
yet so I am sure there's a teeny weeny memory leak on my computer right now :P)std::list<>
to do i. I have a list declared as a private member in the .h file, but in the .cpp file for the class, when I try to use the list, the compiler tells me 'attackList' was not declared in this scope |
delete
them when you stop using them. By instance before you erase it from the map.push_front
a string into the list doesn't seem to work. I have two separate derived classes in which I've written the same code, but it behaves differently in each one...I was getting a termination to do with std::length_error for a while, and then one of them was giving me a bus error when reaching that point...and sometimes one of them will just act like it worked but then when calling displayStatistics() it doesn't show anything listed as having been stored in the list. I just don't know. Here's the code for Hero (the class Dagron is derived from):
|
|
|
|