Declaring function as static

answerme's Avatar, Join Date: Dec 2007
Ambitious contributor
If i declare a function as static what will happen
technosavvy's Avatar
for static functions in C++ go through:

and in C a static function has a name visible in that translation unit only. A
normal function has a name visible across the entire program.

If you were to have two source files with the undermentioned code:
static int fun() {
return 0;
int morefun() {
return 0;
you would get "function already defined" errors for function morefun( ), but fun( ) would compile successfully .

a static function can only be called in the translation unit in which it is defined...
hence a call to a static function from a file where it has not been defined will give a compilation error.

friend why don't you try a bit of googling before u post a question..these kind of information is very very easily available on the net.