Function Overloading

The CCS Compiler has borrowed a C++ feature called function overloading. Function overloading allows the user to have several functions with the same name, with the only difference between the functions is the number and type of parameters.

 

/*
Here is an example of function overloading: Two functions have the same name but differ in the types of parameters. The compiler determines which data type is being passed as a parameter and calls the proper function.
*/


void FindSquareRoot(long *n)
{
/*
This function finds the square root of a long integer variable (from the pointer), saves result back to pointer.
*/

}

void FindSquareRoot(float *n)
{
/*
This function finds the square root of a float variable (from the pointer), saves result back to pointer.
*/

}

/*
FindSquareRoot is now called. If variable is of long type, it will call the first FindSquareRoot() example. If variable is of float type, it will call the second FindSquareRoot() example.
*/

FindSquareRoot(&variable);