Why can't access static file with this pointer?

3035 views pointers
-2

Example I have a program:

class TestStatic
 {
   private:<br>
    static int staticvariable;

   public:<br>
    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

1

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?

JD

Please login first before posting an answer.