+ 1

[solved] Why the value of class member is not changing ❓

https://code.sololearn.com/cz7Fw9rw0088/?ref=app

24th Mar 2020, 12:10 PM
ClassHacker
ClassHacker - avatar
2 Respostas
+ 1
Changing the value of class variable using an object does not affect it, but creating a new variable that shadows the class variable for the particular object. You need to use the class name to change the class variable. Related post: https://www.geeksforgeeks.org/g-fact-42-changing-class-members-JUMP_LINK__&&__python__&&__JUMP_LINK/
24th Mar 2020, 2:33 PM
你知道規則,我也是
你知道規則,我也是 - avatar
0
to change the value of the class member, use A.x = value. if you use an object to change the member, you will just... change the object member value not the class member!
24th Mar 2020, 12:41 PM
John Robotane
John Robotane - avatar