c++ - Adding to a vector of pointers through a class function -
OK, I recently asked a similar question on some time ago, but I was tired and when I Post it, then delivered it. Basically, I have this original class To add new code to the When I use it, it looks like: Now, my problem occurs when I test to see that the firefly information is still there, when it says the My output looks like this: added capacity fireball released Press any key to hold ... Press any key to continue ... The name of the capacity does not appear anymore, because It should have been shown as "fireball" for the second time after the first break I hope that I have explained clearly and given enough information because every time I use the indicator parameter Try and (or passing pointer) do, it always shows me about the function pointer. Without seeing the gatenem () function, it appears that the function itself for std :: cout Capacity does not print the name. This will mean that you have unit which contains a vector of indicator for the
qualification class.
Public: vector & lt; Qualification * & gt; my abilities;
unit and to make it easier to add, the new one is also in the class to add new capacities The function is. Code>
Unreal Eligibility (Capability * Capability) {myAbilities.push_back (Capability); Cout & lt; & Lt; "Capability added" & lt; & Lt; Endl; The court's & lt; & Lt; Ability-> GetName () & lt; & Lt; Endl; }
AddAbility (New Fireball ());
AddAbility () function goes.
cout & lt; & Lt; Player 1- & gt; Myabiliases [0] - & gt; GetName () & lt; & Lt; , just
player1-> myAbilities [0] -> GetName (); In your main function.
Comments
Post a Comment