#understanding classes

4 messages · Page 1 of 1 (latest)

median latch
#

so in a class, public members can be accessed anywhere and private members can only be accessed by the other members in that class. is that correct?

blissful vessel
midnight vortex
#

Hey Silvia,
Yes, you're mostly correct
Public members can be accessed from anywhere (as long as you have the object of the class).
Private members, however, can only be accessed inside the same class not from outside, even through an object.
They are usually accessed using public methods (getters/setters) if needed.