C | Functions | Question 9
What is the meaning of using static before function declaration?
For example following function sum is made static
static int sum(int x, int y, int z) { return (x + y + z); }
(A) Static means nothing, sum() is same without static keyword.
(B) Function need not to be declared before its use
(C) Access to static functions is restricted to the file where they are declared
(D) Static functions are made inline
Answer: (C)
Explanation: In C, functions are global by default. Unlike global functions, access to static functions is restricted to the file where they are declared. We can have file level encapsulation using static variables/functions in C because when we make a global variable static, access to the variable becomes limited to the file in which it is declared.
Quiz of this Question
Recommended Posts:
- C | Functions | Question 10
- C | Functions | Question 8
- C | Functions | Question 11
- C | Functions | Question 7
- C | Functions | Question 11
- C | Functions | Question 2
- C | Functions | Question 3
- C | Functions | Question 4
- C | Functions | Question 5
- C | Functions | Question 6
- C++ | Virtual Functions | Question 10
- C++ | Virtual Functions | Question 1
- C++ | Virtual Functions | Question 2
- C++ | Virtual Functions | Question 14
- C++ | Virtual Functions | Question 9