0
Why the void function setName can change the value of name?
If the variable name isn't in the block code of the function.
2 Answers
+ 1
Assuming you have variable <name> declared in class body (not within any of the methods); a method will have access to the <name> variable.
Note that there is this access modifier thing, it differentiates which are class variables/methods and which are instance variables/methods.
P.S. Share the code in relation with your question if you desire better response. Wild guesses often makes wrong answer. And don't forget to specify the language in Relevant Tags đ
+ 1
A void function is not a const function.