I have a static member function which is merely syntactic sugar for me and I would like its body to appear in place of going through the motions of passing parameters to it. Will
inline static foo(int a) {return a & 0x00000040;}
be inlined just as it would if it was inline
without being static
?
A static member function can access only the names of static members, enumerators, and nested types of the class in which it is declared. Suppose a static member function f() is a member of class X . The static member function f() cannot access the nonstatic members X or the nonstatic members of a base class of X .
A virtual function cannot be global or static because, by definition, a virtual function is a member function of a base class and relies on a specific object to determine which implementation of the function is called.
A class member function defaults to external linkage unless a definition for that function contains the inline specifier.
Can we overload static methods? The answer is 'Yes'. We can have two or more static methods with the same name, but differences in input parameters.
The compiler chooses what it wants to do so we can't say what it will choose to do. That said, the function being static
will not prevent it from being inlined; static
functions are basically free functions with a different naming style and access to the class' private members.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With