Pointers to static member functions

suggest change

A static member function is just like an ordinary C/C++ function, except with scope:

So, if you have access to the static member function and decorate it correctly, then you can point to the function like any normal function outside a class:

typedef int Fn(int); // Fn is a type-of function that accepts an int and returns an int

// Note that MyFn() is of type 'Fn'
int MyFn(int i) { return 2*i; }

class Class {
public:
    // Note that Static() is of type 'Fn'
    static int Static(int i) { return 3*i; }
}; // Class

int main() {
    Fn *fn;    // fn is a pointer to a type-of Fn

    fn = &MyFn;          // Point to one function
    fn(3);               // Call it
    fn = &Class::Static; // Point to the other function
    fn(4);               // Call it
 } // main()

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Pointers to class / struct members:
* Syntax
* Pointers to static member functions

Table Of Contents
8 Arrays
11 Loops
39 Streams
48 Pointers to class / struct members
51 Unions
56 Lambdas
60 SFINAE
62 RAII
67 Sorting
84 RTTI
87 Scopes
104 Profiling
107 Recursion
117 Iteration
125 Alignment
134 Semaphore
136 Debugging
139 Mutexes
142 decltype