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.

12th Oct 2019, 12:00 AM
Frank Castro
Frank Castro - avatar
2 Respostas
+ 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 👍
12th Oct 2019, 3:21 AM
Ipang
+ 1
A void function is not a const function.
12th Oct 2019, 4:22 AM
Sonic
Sonic - avatar