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 unit which contains a vector of indicator for the qualification class.

  Public: vector & lt; Qualification * & gt; my abilities;   

To add new code to the 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; }   

When I use it, it looks like:

  AddAbility (New Fireball ());   

Now, my problem occurs when I test to see that the firefly information is still there, when it says the AddAbility () function goes.

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 cout & lt; & Lt; Player 1- & gt; Myabiliases [0] - & gt; GetName () & lt; & Lt; , just player1-> myAbilities [0] -> GetName (); In your main function.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -