C++ object oriented return value of virtual function in base class
<p>I am making a class which inherits off another and must return the value of a function in the base class... It is confusing so I will let the code speak for itself...</p>

<pre><code>class ParentClass {
public:
    virtual bool getMyVal();
};

bool ParentClass::getMyVal() {
    return true;   // in my program there is a bit more to it
}

class ChildClass : public ParentClass {
public:
    bool getMyVal();
};

bool ChildClass::getMyVal() {
    CalculateMassOfSun();

    return parent::getMyVal();    // Please make sure you read below...
}
</code></pre>

<p>So this is just an example of what I want to do, not the actual code. As you can see, in ChildClass::getMyVal(), is basically needs to do some pre-computation then run the same function in the parent class and return its value. I know that it is a virtual function in the parent, and that I have not gone about invoking the function in the parent the right way - it is how it is done in PHP and the only way I can think of that makes sense to me and hopefully others at the moment.</p>

<p>So how would I go about doing this? At the moment, I have found something along the lines of:</p>

<pre><code>bool ChildClass::getMyVal() : /*ParentClass::*/getMyVal() { ... }
</code></pre>

<p>however it does not return the value here.</p>

<p>Thanks in advance for your responses.</p>
