0

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.

Yash Thakor
  • 129
  • 3
  • 10
Hồng Phúc
  • 408
  • 3
  • 10

1 Answers1

2

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

Hope it helps.

Léopold Houdin
  • 1,515
  • 13
  • 18