answersLogoWhite

0

When a function is declared static at file scope, this means the function has internal linkage only. That is, the function is only accessible to the translation unit in which it is declared. This applies to both C and C++. However, we can achieve the same thing in C++ by declaring a (non-static) function in an un-named (anonymous) namespace. Whether this better represents internal linkage or not is merely a matter of taste.

In C++ we can also declare static functions inside a class. Static member functions differ from non-static member functions in that they do not have access to a 'this' pointer; they are local to the class, not to objects (instances) of the class. As such, they can be invoked without having to instantiate an object from the class.

User Avatar

Wiki User

9y ago

What else can I help you with?

Related Questions

What is the difference between static function and global static function?

'global static'?! There is no such thing.


How do you differentiate between a member function and normal function?

A normal function is any function that is not a member of any class. Normal functions that operate upon a class are referred to as non-member functions, however a non-member function can also be a member of another class. Any class may declare any non-member function to be a friend of the class, in which case the function becomes a friend function.A member function is a member of a class and may be declared static or non-static. Non-static member functions have the following 3 properties:Private access to the class members.Scoped to the class.Must be invoked against an object of the class (has a 'this' pointer).Static member functions have the first two properties only while friend functions have the first property only. Non-member functions that are not friends of the class have none of these properties.


WAP to show the difference between a variable and static variable?

difference between constant and static variables in java


What is the difference between method and function in java?

A function is a piece of code that can be reused by calling its name while a method is a function that is associated with a class. In Java, functions are usually referred to as static methods.


What is the difference between a static variable a global variable and a local variable?

A static variable is a variable allocated in static storage. A local variable is a variable declared inside a function. A global variable is a variable declared outside of any class or function. Note that local variables and global variables can both be allocated in static storage.


What is the Difference between public static void and static public void?

There is no difference between public static void and static public void


What is the difference between static electricity and static discharge?

i love v a g i n a


What is the difference between static and dynamic fighting?

Static stays the same and dynamic is always different.


What are the difference between versions and functions?

Version: static reference to a specific entity of a specific instance. Function: dynamic reference to existing algorithm to perform or execute.


What is the function of static relay?

function of static relay


What is function of static relay?

function of static relay


What is the difference between static and electricity?

Static is electricity. It's just not all neatly contained in a wire.