- Windsor-Essex FIRST Robotics

Intro C++ Programming
What will we cover today
•Understanding the sample code
•Understanding of basic C++ operations and data structures
•Resources for continued learning
Technical Resources
The FRC website has GREAT resources for this years new hardware.
◦ https://wpilib.screenstepslive.com/s/4485
◦ Covers Labview, C++, and Java
More Resources
Chief Delphi
Great resource – A forum with other FRC students, sharing and answering
Sample C++ Code
Sample C++ Code
A variable is a container for data that needs to be used
for other steps.
Int, Float, Boolean are simple data variables
RobotDrive, Joystick are complex objects. These
objects store lots of data in a known structure.
Sample C++ Code
Contain code that can be easily called by other code
If a section of code will be reused in more than one
place, a function is an easy way to keep your code
organized, as well as easy to change in the future
Sample C++ Code
A code loop will loop until conditions are no longer
In this case, we will loop through the tele operated
code until we are no longer Enabled or In Tele
Operated Mode.
Sample C++ Code
Object Structures - RobotDrive
RobotDrive is a data structure that contains both
variables and functions
In C++ these variables and functions can be accessed
using the “.” or “->” to refer to an objects structure.
Example myDrive.arcadeDrive(driveStick)
Sample C++ Code
Object Structures
Jaguar *exampleJaguar = new Jaguar(0);
gyro = new Gyro(1);
double angle = gyro.getAngle();
C++ Coding – Your Turn
#include <iostream>
using namespace std;
int main ()
int i;
cout << "Please enter an integer value: ";
cin >> i;
cout << "The value you entered is " << i;
cout << " and its double is " << i*2 << ".\n";
return 0;
C++ Coding – Your Turn
#include <iostream>
int main ()
using namespace std;
int addition (int a, int b)
int z;
z = addition (5,3);
int r;
return r;
cout << "The result is " << z;
C++ Coding – Get Some Class
#include <iostream>
width = x;
using namespace std;
height = y;
class Rectangle {
int width, height;
int main () {
Rectangle rect;
void set_values (int,int);
rect.set_values (3,4);
int area() {return width*height;}
cout << "area: " << rect.area();
void Rectangle::set_values (int x, int y) {
return 0;
Setting Up a New Project

similar documents