
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
It's not your own, but a totally foreign one with the same type.
What's not yours? That the type is the same?
Are you saying that a constant method cannot change someone else's class?
And when you're replying, please be more specific, I didn't understand what you're trying to say.
What's not yours? That the type is the same?
Are you saying that a constant method cannot change someone else's class?
And when replying, please be more explicit, I did not understand what you mean.
To put it simply. In a constant method, it's impossible to change values of variables declared in the same class where the constant method is located (or declared in its parent). Is it so?
You're the one who doesn't understand what you're writing Can change someone else's class of any type and the same as itself.
Maybe you should watch what you're writing after all. How can a method change a class? Maybe a class object?
And the question was in the statement:
A constant method cannot change its class members.
Alexey gave an example that it can change, so I don't think the statement is correct, I wanted to hear Vasiliy's comment.
Maybe you should watch what you're writing after all. How can a method change a class? Maybe a class object?
And the question was in the statement:
Alexey gave an example that it can change, so I think the statement is wrong, I wanted to hear Vasily's comment.
How about you read more thoughtfully? -"change the values of variables declared"
How can you talk about Alexey's assertion? He didn't just assert it, he confirmed it for real, gave an example, you can throw it into an editor and see when it compiles and when it doesn't.
To put it simply. In a constant method, it's impossible to change values of variables declared in the same class where the constant method is located (or declared in its parent). Is it so?
Maybe you should watch what you're writing after all. How can a method change a class? Maybe a class object?
..
Like this:
No. You do know that each object of a class has its own set of variables declared in that class, right? And a constant method cannot change only the object (i.e. set) from which it was called.
What does the call have to do with it? What matters is the location of the method and variables. If the method and variables are located in the same class, you cannot change. If the class is passed by reference as a parameter, you can.