Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Declaring function as static (http://www.go4expert.com/forums/declaring-function-static-t8390/)

answerme 22Jan2008 10:47

Declaring function as static
 
If i declare a function as static what will happen

technosavvy 22Jan2008 11:37

Re: Declaring function as static
 
for static functions in C++ go through:
http://www.codersource.net/cpp_tutor...functions.html


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:
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.


All times are GMT +5.5. The time now is 09:52.