how do you program a limit switch on c++?
Should probably search Chief Delphi for answers.
However, you would use a DigitalInput object (http://mmrambotics.ca/wpilib/class_digital_input.html) and use the Get() function to check whether the switch is high or low.
The correspondence of TRUE to HIGH or FALSE to HIGH is dependent on your wiring.