Why can't access static file with this pointer?

3035 views pointers

Example I have a program:

class TestStatic
    static int staticvariable;

    TestStatic() {
    this->staticvariable = 0;
    cout << this->staticvariable;

~TestStatic() {}

int main() {
 TestStatic object;
 return 0;

why this pointer can't access staticvariable . I don't understand why.

answered question

1 Answer


Probably because staticvariable is not bound to this but to your class. Check out the following answers:

Hope it helps.

posted this

Have an answer?


Please login first before posting an answer.