The base class does not have access to descendant fields.
Yes, but I defeated it this way:
class C_AO_Agent
{
public:
double c;
double f;
};
class C_AO
{
public:
double cB[];
C_AO_Agent *a;
virtualvoid Init() { }
};
class C_Agent : public C_AO_Agent
{
public:
double g;
class ad
{
};
};
class C_P : public C_AO
{
public:
void Init()
{
a = new C_Agent;
C_Agent *agent = (C_Agent*)a; // Приведение типов
agent.f = 5;
agent.g = 7; //теперь есть доступ к g!!!
agent.c = 8;
}
};
voidOnStart()
{
C_AO *ao;
ao = new C_P;
ao.Init();
//тут нам нужен доступ только к f и cPrint (ao.a.f);
Print (ao.a.c);
// Удаление объектовdelete ((C_Agent*)ao.a);
delete ao;
}
if you move the mouse pointer over the name of a variable or function and press Ctrl, you move to the definition or declaration of this variable (function). This is implemented in almost all IDEs, only when Ctrl is pressed, the variable is highlighted and underlined. It is not in ME.
Ihave not found this feature in the help. The same thing can be achieved by pressing Alt+G, but it is still more convenient to use the mouse.
The question in the picture is:

code:The question in the picture is:
code:
Forum on trading, automated trading systems and testing trading strategies.
Features of mql5 language, subtleties and techniques of work
Andrey Dik, 2024.02.16 06:05
The base class does not have access to the fields of descendants.
The base class does not have access to descendant fields.
this is a working version of what was required.
yes, but defeated this way:
is a working version of what was required.
It's very buggy.
Show me an example
Show an example, and anyone can offend an artist).
Example of what?
The task was to get access to an object, not to organise correct deleting of objects. Deleting is always easier than creating))
if you move the mouse pointer over the name of a variable or function and press Ctrl, you move to the definition or declaration of this variable (function).
This is implemented in almost all IDEs, only when Ctrl is pressed, the variable is highlighted and underlined. It is not in ME.
Ihave not found this feature in the help.
The same thing can be achieved by pressing Alt+G, but it is still more convenient to use the mouse.