Delphi - access to object instance data from another object

I have my main form. Form_Main

Creates two instances of two classes.

Candle_Data : TCandle_Data;
Indicator_2700 : TIndicator_2700;

In order for Indicator_2700 to correctly calculate its values, it must have access to the candle data in obect Candle_Data from one of its methods. So how can Indicator_2700 access data inside Candle_Data? Should Form_Main pass it as an argument during constructor?

Both class declarations are in their own unit file.

+3
source share
3 answers

TIndicator_2700may have the property to associate it with an instance TCandle_Datarelated to its own instance, or you must specify it as an argument to the method that should access the data.

, TCandle_Data Indicator_2700 , .

+2

() :

  • , . , Candle_Data, , .
  • Candle_Data , .
  • .

, , .

+2

unit.

, . , . , .

, , :

  • , / (, TCar TAirplane Transport),
  • , , (, Transport Fuel: TCar TDiesel, TDiesel TCar). . Delphi : " " ". , nono.
  • Declare a new base class in a new module only if the base class has a common object, but there are no final descendants (for example, it is TFuelused by all transport classes, such as TCar, TAirplaneand THorse, but TFood(descendant TFuel) only THorseand is used TPerson).

To link both classes together, see the answers already provided.

0
source

All Articles