Information générale
Catégorie:
Programmation Orientée Object
Versions des environnements
You have not actually overridden the value of mynumber in the class.
If I understand your question, you are unsure why the o2.mynumber value returns 1234 even though you have created the o1 object an set the o1.mynumber property to 5678? You need to understand that an object is an instance of a class. You cannot change the value of class properties at runtime you can only change the calue of object properties so the o1 object is quite independent from the o2 object and nothing that you do to o1 will have any influence over o2 in the example you have provided.
does that explanation make sense?
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement