Yes. Any function can be overloaded. However you cannot override a static member function. Only instance members can be overridden.
Static member functions, member function templates and constructors cannot be virtual.
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.
function of static relay
'global static'?! There is no such thing.
Every non-static member function has a hidden pointer parameter named this which refers to the instance of the class the function was invoked against. For a given class, C, the type of the hidden this pointer is const C* but if the function is declared const, the pointer is const C* const. When referring to any class member, m, from within any non-static member function, this->m is implied.
Yes, a static method may be overloaded.
A static function is a member function that is not associated with any instance of the class; it has no this pointer.
Always.
Static member functions, member function templates and constructors cannot be virtual.
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.
"this" can only be used within the body of a non-static member function of a class and refers to the current instance of that class. Typically, we only refer to "this" instance when a non-static member function returns a reference to the current instance.
Static functions are tied to a class, not to a particular object. A static function can only access static variables because it has no knowledge of member variables.
function of static relay
function of static relay
'global static'?! There is no such thing.
No. To understand how friend functions relate to static functions you first need to understand the three qualities of a normal member function (an instance member function): 1. The function has access to the private aspects of the class in which it is declared. 2. The function is scoped to that class. 3. The function must be invoked on or from within an object of that class. A static function only has the first two qualities (so no instance of the class is required) while a friend function only has the first quality (so is neither scoped to the class nor requires an instance of the class). All three share the first quality only but that alone does not make them similar. It is the qualities they lack that sets them apart.
Static data members are local to the class in which they are declared. That is, they are shared amongst all instances of the class, unlike instance variables where each instance has its own set of variables. In addition, static data members are also accessible to static member functions, even when no instances of the class actually exist. So if static data members are accessible even when no instance exists, how are we to initialise them? A member function is no use because that would require an instance. And a static member function isn't an option either because then the onus is upon the user to ensure that the method is called BEFORE any instances are created, which completely destroys the encapsulation of the class (not to mention the fact a static member function would require a local static variable in order to determine if it had already been called or not). The simplest solution is to initialise all static data members from outside of the class declaration. Typically we do this from within the class CPP file however we can also do it in the header file, so long as it's not declared within the class declaration. As with all static variables, the initialisation statement is executed at compile time, thus ensuring the member is fully initialised at runtime.