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
Constant method is another example of the proverb "we wanted to do better, but it turned out to be the same as always". I think this is a motto for C++ at all. There is no practical use but it significantly complicates designing of OOP-programs because you constantly need to control the type of object being modified (it must be constant as well).
Can I give you an example of what you wrote about?
The constant method is just another example of the proverb "we wanted things better but it turned out as usual". I think it's a motto for C++ at all. It is of no practical use but it significantly complicates the design of OOP programs because you constantly need to control the type of the object being modified (it must also be constant).
))) I've got an old Stroustrup book lying around, if burglars break into the house, I can easily beat them off with it, it weighs like a brick )) The old man put so much trouble in his tongue...
I remember a long time ago I got chased around in a job interview, they asked me a question and I couldn't answer it accurately. They brought me a book like this, I read it, and I asked, "Do you use it yourself?
I asked, - Do you use it yourself? - Guys are laughing, it's OK, no one has yet answered this question correctly, as no one uses it.
By the way, I've got a book on pluses from the early 90s, before the first standard was adopted. A normal digestible paperback book. But then Ostap got carried away ))
Can I have an example of what you wrote about?
Alexey wrote an example. A constant method cannot change its class members. What seems to be the problem? Just don't use the const modifier. But then there are difficulties in inheritance (especially fromstandard library): designer defined virtual method const, but in derived class, method needs to change something in its data - and there's a plug because of const. Without it, the method will not be overridden, and with it, the derived method cannot change its own class data.
What is the main mistake in introducing such a modifier for class methods? The main principle of inheritance is violated: specialization and refinement. The base class prohibits the derived class method from working with its internal data. And there should not be such a situation.
Sharpe reeks a mile away ))
There's nothing const obstructing, no need to blather on.
Sharpe reeks a mile away ))
I'm not denying it. Sharpe really is a perfect, great and beautiful language.
Const does not complicate anything, don't blah-blah
Ok, let's say one can always get rid of const. But why don't you briefly explain by example, what does const do? What is its real use? By example, and preferably not written out of thin air.
...
What is the main mistake of introducing such a modifier for class methods? The main principle of inheritance is violated: specialization and refinement. The base class prohibits the derived class methods from working with its internal data. But there mustn't be any such thing.
Maybe it is some part that is passed from creators to simple users. Like the start function in the Expert Advisor and the Bid and Ask variables.
When you make everything yourself, there is no sense to bother with all sorts of const.
I'm not denying it. Sharp is indeed a perfect, great and beautiful language.
...
Great. But it's a long way from perfect.