View Single Post
  #8   Spotlight this post!  
Unread 29-01-2009, 14:40
Pancake Pancake is offline
Registered User
FRC #0991 (The Dukes)
Team Role: Photography
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Phoenix
Posts: 11
Pancake is an unknown quantity at this point
Re: define a new class(C++)

Typically, there's two files, the header file and the CPP file.

Example Header
Code:
// Camera.h
#ifndef CAMERA_H
#define CAMERA_H

class Camera
{
public:
    void doSometing();
};

#endif
Then make a .cpp file with the same name as the header file:
Code:
// Camera.cpp

#include "Camera.h"

void Camera::doSomething()
{
    printf("Doing something...");
}
Now when you get to the robot code, all you need to do is simply include the "Camera.h" file:

Code:
//MyRobot.cpp
#include "Camera.h"

class MyRobot : public SimpleRobot
{
    /* Code ommited for simplicity */
    void Autonomous()
    {
        Camera c();
        c.doSomething();
    }
};

START_ROBOT_CLASS(MyRobot);
Hope this example helps...
__________________
Team Webmaster
Reply With Quote