Search code examples
c++classstaticstatic-members

Why are the static members of a class the same for all objects?


Why don't we have different copies of static variables for the different objects?


Solution

  • Because they would be instance members then.

    The primary characteristic of static members is that they're shared by all the instances of the class.