Thread: Functions
View Single Post
  #8   Spotlight this post!  
Unread 14-02-2012, 10:56
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Functions

Just to try to add some clarity, you don't ever initialize a function, you can declare and define a function. It's typically good practice (probably a matter of opinion, but isn't neccessary) to declare your function before you define it; alternatively, you can simply define the function without declaring it at all (in which case the definition is the declaration)

Code:
class SomeRobot
{
void NewFunction(void); //declartion of new function prior to definition
... some other stuff...
void NewFunction(void) //definition of new function
{
  ...some action to run during autonomous...
}

void OtherFunction(void) //Definition of OtherFunction(which is also the declaration)
{
... some stuff... 
}
public:
Autonomous()   
{
   NewFunction();
   OtherFunction();
   LastFunction();
}

void LastFunction(void)  //you can also declare it later, inside a class it doesn't need to declared before it's used
{
 ... some stuff...
}
}

Last edited by DjScribbles : 14-02-2012 at 11:02. Reason: fixed a copy paste error
Reply With Quote