Vladislav Boyko / Publications
Forum
Questions about OOP
I created this topic in order to avoid creating a separate topic for each OOP question (I have already created several of these)
Why release array memory when exiting a function?
Stack # Therefore, for large local data you should better use dynamic memory - when entering a function, allocate the memory, which is required for local needs, in the system ( new , ArrayResize() ), and when exiting the function, release the memory ( delete , ArrayFree() ). Why does the
How to find out the reserved memory of a dynamic array?
I'm talking about memory reserved using the third parameter of the ArrayResize function . Is there a way to find out how much memory is reserved for an array
Semicolon after constructor body in documentation
Is this a typo or does this make some sense? https://www.mql5.com/en/docs/basis/types/classes#initialization_list class CPerson { string m_first_name; // First name string m_second_name; // Second name public : //--- An empty default constructor
What is the point of constant class members?
I'm talking about const members of simple types that are not static (and are not pointers). class CFoo { private : const int i; public : CFoo() { i = 1 ; // 'i' - constant cannot be modified } }; Why is it possible to make members of simple types const? Such a member will not
Passing an array of object pointers
Using the const specifier I can protect an array of objects from being resized: class Foo { }; void resizeObjects( const Foo &arr[]) { ArrayResize (arr, 1 ); // 'arr' - constant variable cannot be passed as reference } Why doesn't this work for an array of pointers? class Foo { };
Why does the compiler ignore the definition of a method in a class in which it is declared as PURE?
This code compiles without any errors or warnings: class CBase { private : virtual void pureMethod() = 0 ; }; void CBase::pureMethod( void ) { Alert ( __FUNCTION__ ); } Is it normal for the compiler to ignore method definition? This is deliberately incorrect code that contradicts itself
How to choose between structure and class?
In this topic, I propose to either create some list of rules for choosing between a structure and a class, or state that both options are equivalent in terms of performance
Has anyone come across a ravioli code?
My question is in the context of this discussion: https://stackoverflow.com/questions/2052017/ravioli-code-why-an-anti-pattern The code that I come across on MQL often lacks levels of abstraction and modularity. I would be interested to see an example of code with an excessive level of abstraction
Changing the access specifier for a virtual function
Can I change the access to a base class method by using a different access specifier when overriding the method in a descendant? class CBase { public : virtual void virtualMethod() {}; }; class CTest final : public CBase { private : virtual void virtualMethod() override {}; }; I want to