
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
I forgot about encapsulation. And it can be deleted. And there are no constant pointers here.) Anyway, singleton is not the best pattern.
But at least there are some nice templates. For classes I would probably only dream of.
We were talking about static class members. Besides, in my example m_a is a private member. And such class members can be accessed only from instances of the class. So, the variable's value cannot be changed anywhere in the code, except on instances of the class. It is a matter of writing safe code which eliminates a lot of possible future bugs.
well, i put public thinking otherwise, removing it will change relative to statics - from within the class - nothing ?!
However,not being able to declare class members statically would result in the need to declare this dataglobally in the program.
The topic was left unanswered.
it's the coolness of mql that's being touted.
don't bother with the wording
Someone was yelling about singleton
Are there plans to extend the templates to classes and explicit parameter setting? Otherwise it's blaming me and telling me, that I want too much.
P.S., it would be more correct to declare SomeClassclass insideSingleton (thenyou can createonly one instance ofSomeClass), but it's more obvious, though not correct.
I've seen it all before. I was wondering how to apply it specifically to my structure. Not just to see it copied from some source. I can do that too)
And in general, I understood, on Igor's advice, that this probably won't be useful to me. So I'm not talking about this pattern anymore. And as for the dodgy documentation, which differs from the C++ one, that's obviously true. But, again, there's nothing we can do about it.
We'll have to write at least as much as possible for now. Until an alternative is available.
Dear Sir, what was wrong with this post???
If class or structure variables don't lose their values during program execution, then why are they declared as static here ?
They are in the public section, you can say that as in the structure...
You are either obtuse or obtuse, sorry to be blunt, it's written in black and white:
For example, we have aCParserclass, intended for parsing texts, and weneed to countthe total number of words and characters processed.It is enough to declare the requiredclass members as static and initialize them globally.Then all instances of the classwill use common word and character counters when working.
Where ever there is a reference to:
Class or structure variables lose their values at runtime
It says that preserving OOP principles and not creating global variables, we can count the number of some words with the help of a static class member,
it (the static class member) is created as a single instance and does not depend on the number of created objects of a given class.
How do the incomprehensible attacks on the structure and class, and the problems you've made up yourself,
concern the fact that you don't understand the basics of OOP and storage duration, as a composite concept of variable properties in general???
Dear Sir, what was wrong with this post?
If you can't read, that's your problem. Here is a quote of what I was asking. If I misspelled somewhere or wrote something wrong in a hurry, it's because "smart guys" like you blabber on and on. If you know how to read, here's a permanent link to a post specifically for the especially cluelesshttps://www.mql5.com/ru/forum/152923/page6#987432
You haven't figured out in two days that static behaves differently in stuct and class?
the structures seem to be taken from c and only a little bit pumped up in terms of inheritance,
As for classes, they are full-fledged.
Because of this, you don't have to reserve space for a static variable in structures
but you have to reserve space in classes, otherwise you won't: