Which of the following is not a consequence of declaring the member variable count of my_class as static?

Advertisement

class my_class {
public: static int count;
}

  • The variable cannot be modified by any part of the code in the same application or thread. However, other threads may modify it.
  • The variable exists even when no objects of the class have been defined so it can be modified at any point in the source code.
  • The variable is allocated only once, regardless of how many objects are instantiated because it is bound to the class itself, not its instances.
  • All objects that try to access their count member variable actually refer to the only class-bound static count variable.
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Comment

Share via
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.