title: Set functions won't work for some reason
body: <p>I'm working on a simple console application to prototype a method of calculating battle between two large units of medieval soldiers. The idea is I'll set up the calculations, and run the program several times with different parameters to get a feel for it and if it's what I want. Anyways, on to the problem.</p>
  
  <p>Each of the two units is represented by a Unit class. The class includes variables for "attack", "defense", "tactics", and "unit size" as well as a few others which I'm commenting out and ignoring until I fix this issue. Here's the code for the class header:</p>
  
  <pre><code>#ifndef UNITS_H
  #define UNITS_H
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  class Unit
  {
    public:
        int attack;
        int defense;
        int charge;
        int brace;
        int tactics;
        int unit_size;
  
    public:
        bool isAlive;
        std::string name;
        Unit(std::string name_target)
        {
            name = name_target;
            attack = 1;
            defense = 1;
            charge = 1;
            brace = 1;
            tactics = 1;
            unit_size = 1;
            isAlive = true;
        }
  
        float GetAttack() {return (float)attack;}
        float GetDefense() {return (float)defense;}
        float GetCharge() {return (float)charge;}
        float GetBrace() {return (float)brace;}
        float GetTactics() {return (float)tactics;}
        float GetSize() {return (float)unit_size;}
  
        void SetAttack(int change) {attack = change;}
        void SetDefense(int change) {defense = change;}
        void SetCharge(int change) {charge = change;}
        void SetBrace(int change) {brace = change;}
        void SetTactics(int change) {tactics = change;}
        void SetSize (int change) {unit_size = change;}
  
        void TakeCasualties (int casualties);
        int Defend(Unit enemy, float base_chance, float base_multiplier);
        void DisplayStats();
  
      };
  
  #endif // UNITS_H
  </code></pre>
  
  <p>Sorry if it's sloppy, but I'm a bit of an amateur.</p>
  
  <p>I would include the .cpp code for the class, but everything in there works fine. I've done test runs with just the default values with no issue. The only problem I have is changing the values after they're constructed.</p>
  
  <p>In main.cpp I have a function AssignStats(Unit unit_target) which I call once the two Units are constructed. I call it on each one in turn. The code for that is as follows:</p>
  
  <pre><code>void AssignStats (Unit unit_target)
  {
      int x;
      cout &lt;&lt; unit_target.name &lt;&lt; endl;
      cout &lt;&lt; "Value for attack?" &lt;&lt; endl;
      cin &gt;&gt; x;
      cout &lt;&lt; x &lt;&lt; endl;
      unit_target.SetAttack(x);
  
      cout &lt;&lt; "Value for defense?" &lt;&lt; endl;
      cin &gt;&gt; x;
      unit_target.SetDefense(x);
  
      //unit_target.SetCharge(x);
      //unit_target.SetBrace(x);
  
      cout &lt;&lt; "Value for tactics?" &lt;&lt; endl;
      cin &gt;&gt; x;
      unit_target.SetTactics(x);
  
      cout &lt;&lt; "Value for size?" &lt;&lt; endl;
      cin &gt;&gt; x;
      unit_target.SetSize(x);
  }
  </code></pre>
  
  <p>As far as I can tell, this code should work. However, when I display the stats of each Unit afterwards, it shows the default values put in by the constructor. For the life of me I can't figure out why my Set functions aren't working. I rewrote the code a little earlier to check if they were getting input right, like so:</p>
  
  <pre><code>void Unit::SetAttack()
  {
      int x;
      std::cout &lt;&lt; "Input target value for attack." &lt;&lt; std::endl;
      std::cin &gt;&gt; x;
      std::cout &lt;&lt; x;
      attack = x;
      std::cout &lt;&lt; attack;
  }
  </code></pre>
  
  <p>I would input 10, and each of the couts would show me 10 right back, even the one that supposedly displayed the attack variable of the class, but later on when I called DisplayStats(), it would show everything to be at default values again.</p>
  
  <p>Can someone more experienced than me please clear this up?</p>