Access without an object of the class

The code in main accesses the class variable three times in succession with no requirement to instantiate an object of the class.

The scope resolution operator (::) is used in conjunction with the class name to access a class variable in the absence of an object.

The first access displays the initial value of the variable.

The second access modifies the value of the variable.

The third access displays the modified value.

The output

The program displays the following output: