Don't understand how this C++ method works, and want to do something similar
<p>I'm trying to add another function to a large program I've been working on. It's a 3D game, and a lot of it was built before I got here. If I want to add something, I'll usually look for other places where something similar has been done and make my changes based off that. In this instance however the method I'm trying to learn from is very complex and I don't really know what is going on (and thus don't know what I need to change about it to make it do what I want it to do).</p>

<p>Here is the normal method:</p>

<pre><code>    class Action_GoToZone : public Action {
    public:
        Action_GoToZone() {}
        void eval(const Dialog&amp; dialog, State&amp; state) const {
            ZoneParser::getSingleton().load("../media/zones/" + mZoneFilename, false);
            GameState::getSingleton()._changeState("GameMode");
        }

        static Action* Create(const Script2::Parser::List&amp; list) {
            Action_GoToZone* action = new Action_GoToZone();

            if(list.size() != 1)
                throw Translator::TranslateException("GoToZone Action takes exactly one parameter");

            const Script2::Parser::ListElement&amp; e1 = list.front();
            if(!e1.mIsIdentifier)
                throw Translator::TranslateException("GoToZone Action only takes identifiers");

            action-&gt;mZoneFilename = String(e1.mIdentifier.mString);
            action-&gt;mReturnFilename = ZoneParser::getSingleton().getLastFilename();

            return action;
        }

    private:
        String mZoneFilename;
        String mReturnFilename;
    };
</code></pre>

<p>All I want my method to do is to call a function within a different class. Here is what I attempted:</p>

<pre><code>class Action_SetJob : public Action {
    public:
        Action_SetJob() {}
        void eval(const Dialog&amp; dialog, State&amp; state) const {
            GameModeState::changeJob(1); //This is the class/function I want it to call.
        }

        static Action* Create(const Script2::Parser::List&amp; list) {
            Action_SetJob* action = new Action_SetJob();

            if(list.size() != 1)
                throw Translator::TranslateException("SetJob Action takes exactly one parameter");

            const Script2::Parser::ListElement&amp; e1 = list.front();
            if(!e1.mIsIdentifier)
                throw Translator::TranslateException("SetJob Action only takes identifiers");

            action-&gt;GameModeState::changeJob(1);

            return action;
    private:
        int changeJob;
        }   
    };
</code></pre>

<p>I don't really know what action-> is for... I tried it with taking out <code>action->GameModeState::changeJob(1);</code> and all content below that but that threw up errors.</p>

<p>This probably isn't enough information to solve the problem, but I'd be happy with any explanation about the method, if you can.</p>
