That is one way to do it. However, instead of declaring the Relay as a pointer (*) you can do it this way:
Code:
class Team1771Robot : public SimpleRobot {
RobotDrive driveTrain;
Joystick leftStick;
Joystick rightStick;
Shooter mainShooter;
Relay mySpike; //Declare your spike's name here
public:
Team1771Robot(void):
driveTrain(LEFT_DRIVE_MOTOR_PORT, RIGHT_DRIVE_MOTOR_PORT),
leftStick(LEFT_JOYSTICK_PORT),
rightStick(RIGHT_JOYSTICK_PORT),
mainShooter(SHOOTER_TENSION_PORT, SHOOTER_RELEASE_PORT),
mySpike(MYSPIKE_PORT) //Put whatever slot the spike is.
{
}
;
Later on in your code, say, in the teleop, you can say
void OperatorControl()
{
while(isOperatorControl() && !isNotDisabled())
{
mySpike.Set(Relay::kOff); //Or forward, reverse, etc.
}
}