C Programming (Turbo C++ Compiler) - Static Functions
Static functions in a file restricts the access level to the functions on that file only.
Example for static function is given below:
Source Code
#include <stdio.h>
static const char* GetWelcomeMessage()
{
static char msg[] = "Welcome to my static function\n";
return msg;
}
int main()
{
// GetWelcomeMessage can only be accessed in the current .CPP file
printf(GetWelcomeMessage());
// It will display Welcome to my static function as output
}
Output
Welcome to my static function
|