Patrick Labelle
Patrick's Blog

Patrick's Blog

New revelation on static/non-static properties

New revelation on static/non-static properties

Patrick Labelle
·Feb 18, 2021·

On a recent challenge one of the tasks was to code a system that could add or subtract rational numbers through multiple instantiations of a Rational class.

When I was creating the code and got to the part of testing the math, although we were creating a second Rational object it kept the properties of the original which ended up being a great example of static/non-static.

Static members are unique, as in all objects of that class share that copy and if we edit it in any way then all future objects end up having the value of the previous instantiation.

 
Share this