C++ static member

2 views
Skip to first unread message

Zorro

unread,
May 16, 2024, 7:50:15 PM5/16/24
to computer.lang.Z++
I will only mention that a class with a static member is effectively a namespace, and leave other issues for someone else to discuss.

Z++ uses the term common, instead of static. Only data members can be declared as common, not the methods of a class.

The purpose of a common member is that all instances of a class will have a single copy of the member. Thus, if one instance changes a common member,  the change is reflected to all instances.

Z++ declaration of a common member allows the specification of a list of methods that are allowed to change the member. The visibility of a common member is the same as any other member, and does not need a (static) method to see its value.

Quite appropriately, unlike C++ you cannot see the value of a common member until you create an instance of the class. That is because you cannot call a method until you create an instance of the class. After all, a class is not a namespace.

Reply all
Reply to author
Forward
0 new messages