Pages: [1]   Go Down
Author Topic: Calling to super fails  (Read 336 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I have a class called SubSystem that implements a method void description(). In my subclass I then try to call super's implementation, but I get the following

error: 'super' was not declared in this scope.

Here is the code:
Code:
class MachineGun : public AirplaneSubSystem
{
    public:
        MachineGun(char *name, int led);
        ~MachineGun();
        void run();
        void setOn(boolean flag);
        boolean isOn();
        void description();

    private:
        int myLed;
        boolean myIsOn;
        int myState;
        unsigned long myThreshold;
        unsigned long myTimestamp;
};

void MachineGun::description()
{
    super.description();
    Serial.print(" isOn = ");
    Serial.print(myIsOn);
    Serial.print(" state = ");
    Serial.print(myState);
}

Any help is greatly appreciated.

Greg
Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Greg--

"super" is a java keyword.  Assuming you mean to call the base class implementation of "description", use this C++ syntax instead:

Code:
void MachineGun::description()
{
    AirplaneSubSystem::description();
    Serial.print(" isOn = ");
    Serial.print(myIsOn);
    Serial.print(" state = ");
    Serial.print(myState);
}

Mikal
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Mikal, the links I browsed on google was saying to use super.method(); They're off my christmas card list now!
Logged

Pages: [1]   Go Up
Jump to: