Which statement is true when declaring the member variable count as static?

Advertisement

class my_class{
public: static int count;
};

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

Send this to a friend