Go Down

Topic: Calling to super fails (Read 377 times) previous topic - next topic

Greg

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: [Select]
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

mikalhart

Hi Greg--

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

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


Mikal

Greg

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

Go Up