c++ Passing a value the wrong way?
<p>When i am passing an object to a function, I am getting undesired results. It seems to happen when I pass a <code>Character</code> through a <code>Mage</code>'s action() function.</p>

<p>Here are some snippits of my code:</p>

<h3>character.h</h3>

<pre><code>    class Character {
    public:
        Character();
        int getMaxLives() const;
        int getMaxCraft() const;

    protected:
        maxLives;
        maxCraft;
    };
</code></pre>

<h3>character.cpp</h3>

<pre><code>    #include "character.h"

    Character::Character () {
        maxLives = 5;
        MaxCraft = 10;
    }

    int Character::getMaxLives() const {
        return maxLives;
    }

    int Character::getMaxCraft() const {
        return maxCraft;
    }
</code></pre>

<h3>mage.h</h3>

<pre><code>    #include "character.h"

    class Mage {
    public:
        Mage();
        void action(Character c1);
    };
</code></pre>

<h3>mage.cpp</h3>

<pre><code>    #include "mage.h"   

    Mage::Mage () { ... }
    void Mage::action(Character c1) {
        cout &lt;&lt; "Max Craft: " &lt;&lt; c1.getMaxCraft() &lt;&lt; endl;
        cout &lt;&lt; "Max Lives: " &lt;&lt; c1.getMaxLives() &lt;&lt; endl; 
    }
</code></pre>

<h3>driver.cpp</h3>

<pre><code>    int main () {
        Character c1;
        Mage m1;

        m1.action(c1);
</code></pre>

<hr>

<p>My ouput gives me the following:</p>

<p>Max Craft: 728798402 (The number varies)</p>

<p>Max Lives: 5</p>

<hr>

<p>However, if in my diver, i do: </p>

<pre><code>cout &lt;&lt; "Max Craft: " &lt;&lt; c1.getMaxCraft() &lt;&lt; endl;
cout &lt;&lt; "Max Lives: " &lt;&lt; c1.getMaxLives() &lt;&lt; endl; 
</code></pre>

<p>I get:</p>

<p>Max Craft: 10</p>

<p>Max Lives: 5</p>

<p>Any ideas?</p>
