There are cases in our code when we use the negated value of the Y-axis for a Joystick. I know this is (really) easy to do, but for convenience, I’d love to extend the Joystick class to include a member function that would do it automatically—I think the resultant code would read a little more intuitively.
So I tried writing this:
#include "WPILib.h"
// some code...
class MyNewAndImprovedJoystickClass : public Joystick
{
public:
virtual float GetNegativeY() //
{
return -GetY();
}
};
// more code...
But WindRiver returned the following error:
C:/WindRiver/2013/SimpleTemplate/MyRobot.cpp:33: error: base `Joystick’ with only non-default constructor in class without a constructor
And, well, I’m not sure what that means.
I understand that this issue on its own is an unimportant one. But I’m doing something wrong, and I’d like to know why. Besides, knowing more about C++ and WPILib can’t hurt me.
Edit:
I found a WPILib-extending library that includes an extended Joystick class. After looking there, I tried rewriting the class as follows, and built without error:
class MyNewAndImprovedJoystickClass : public Joystick
{
public:
MyNewAndImprovedJoystickClass(UINT32 port) : Joystick(port) {}
virtual float GetYAdj()
{
return -GetY();
}
};
I haven’t tested this on the robot yet, but here’s hoping.