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
This means you have to create an instance using the new operator.
There's one thing I don't understand. What good reasons are there to force the use of the new operator? Is it all right without it?
It is needed if you want to create objects dynamically. If you don't know in advance how many objects and what types of objects will be needed.
Так я вот одного не пойму. Какие веские причины принуждают к использованию оператора new ? Без него типа никак?
It's needed if you need to create objects dynamically. If you don't know beforehand how many objects and what types of objects are required.
You can use dynamic class arrays. In MQL this will work. In C++, there may be problems with class initialization of class members. That's why it's better to put a smart pointer in the array. So you don't have to deal with class initialization and memory clearing.
How does this construction "read"?
Ah, in particular:
I'm looking at it and I don't get the gist of what's going on...How does this construction "read"?
ptr is converted to cFather type (class) and its (cFather) method GetData() is called
something like this...
ptr is converted to cFather type (class) and its (cFather) method GetData() is called
something like this...
That's a weird thing... I thought so approximately, but... it's too much to be cast to a type (class). In programming anyway, as far as I've heard, it is not recommended to cast to a type (class). But it's not just standard type conversion - it's rather class conversion.
Well, let's return to this code once again:
Here in the parameters of the f function prototype we can clearly see that the f function takes a method of the cFather class in the parameters. Further we see the following situation in the START code:
f(ptr); // вернет 3
This is where the f function takes a pointer to the cChild class, rather than a method of the cFather class. Since cChild obj, *ptr = GetPointer( obj );
What's the logic behind this?
mm... logic where ?
in the f() method, I think the logic is that the incoming parameter will be handled correctly for cFather (or its descendants)
mm... logic where ?
in the f() method, I think the logic is that the incoming parameter will be correctly handled for cFather (or its successors)
I.e.
here *p is a pointer to cFather?
At the same time, I'm studying C++ and am a bit confused by similar vocabulary. Pointers are not the same here though.
I.e.
here *p is a pointer to cFather?
At the same time, I'm studying C++ and I'm a bit confused by similar vocabulary. The pointers here are not the same though.
It's been a couple of weeks since I've had a question. I decided to ask it. It's not too complicated, but logically I'm wondering if this is an option. Here is the code:
There are only 2 public functions in this code:
And the 2 private functions are called directly through the public function, or rather the public function, at the moment of need. What is interesting is that the void SetName(string n) function has the parameter n, but both private methods private: string GetFirstName(string full_name) and string GetLastName(string full_name) for some reason do not have the same parameter. But if you take this very code (not the other one), the private methods are called through the public ones with the same parameters and there is no other way. So why should I give different names to the parameters?
I hope the question is clear.