Pointers to static member variables

suggest change

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

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

class Class {
public:
    static int i;
}; // Class

int Class::i = 1; // Define the value of i (and where it's stored!)

int j = 2;   // Just another global variable

int main() {
    int k = 3; // Local variable

    int *p;

    p = &k;   // Point to k
    *p = 2;   // Modify it
    p = &j;   // Point to j
    *p = 3;   // Modify it
    p = &Class::i; // Point to Class::i
    *p = 4;   // Modify 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 variables

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