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
How are cross-links between descendant classes that have a common root somewhere deep in the hierarchy established?
For example: Class F and class Z are the end links of an inheritance chain with a common root in the hierarchy, class A.
How can one get data or methods of class Z from class F?
You can't. There is no such thing. But there is no need to.
After creating objects you can pass a pointer from one object to the second and a pointer from the second object to the first.
Although, if we are speaking specifically about the class, you can address any object through two colons. But what for do you need it? It is needed sometimes, of course, but it is an extremely minor OOP feature.
No way. There's no such thing. But you don't need to.
After creating objects, you can pass a pointer of one object to the second and a pointer of the second to the first.
Although, if we are speaking specifically about the class, you can refer to anything through two colons. But what for do you need it?
Example: Class F stores Colour and Length methods, and Class Z stores Sound and Width methods.
An Object appears that has two properties, Length and Width, but they are calculated by different F and Z classes. What to do? Create a separate class with repetition of these methods, or how do I access them? (With a four dots?).
Example: Class F stores Colour and Length methods, and Class Z stores Sound and Width methods.
An Object appears that has two properties, Length and Width, but they are calculated by different F and Z classes. What to do? Create a separate class with repetition of these methods, or how do I access them? (With a four dots?).
You could create a new class and include the F and Z classes in it.
You can create a new class and include classes F and Z in it.
You can create a new class and include classes F and Z in it.
Or you can make a method in the class where you want the data of the other class to get a pointer to the required class.
A class "bow"? Got it. Thanks.
You can just get a pointer to the class you want, and use the pointer to get a class object. But you have to be careful not to get a pointer to an empty or new class object.
You can simply get a pointer to the desired class, and use the pointer to get a class object. But you have to be careful not to get a pointer to an empty class object.
A "bowing" class? I see. oops.
In the example
Class Y contains variables with types of classes F and Z.
But if you already have objects of classes F and Z created and used somewhere, you will not be able to access them in object Y. There will be two new objects of classes F and Z in object Y.
And to get access to the objects of classes F and Z created earlier and already used, you need to get references to objects F and Z in class Y - then class Y can operate with those data, which are already written in F and Z, instead of using new and pristine F and Z.
But if you create such an object, then F and Z in it will give access to classes F and Z, and you have to fill them only via class Y - again, give access to objects F and Z from it, get a pointer to the object you need and work with it by the pointer.
Subtleties. I see. Hierarchy of inheritance is convenient when the data is clearly classifiable, predefined and unambiguous. As objects get more complex, combinations of methods and properties not intended for classes may appear and this requires creation of "bindings" - i.e. cross-links between classes. This is not always convenient and may break the beautiful distribution scheme and force it to be revised.
You don't need to break anything - you just need to add a method to the class that gives a pointer to the required object of another class.
In the recent articles I've passed pointers to previously created and working and having accumulated data collectionclass objects and the current account object in trade objects in this way. And the trade class handles them as if it had always had them.