Now suppose that trade_union
is the name of a variable of type
trade
. Then, if the memory chunk identified by trade
is
occupied by a stock_trade
object, you access that stock_trade
object as though it were in a structure variable named stock
:
*-- Produces stock_trade object from the union | v ------ trade_union.stock
Then, if you want to get at the stock_trade
object's priceearnings
ratio, you go after the value of the pe_ratio
structure variable:
*-- Produces stock_trade object from the union | v ------ trade_union.stock.pe_ratio --------- ^ | *-- Produces price--earnings ratio from the stock_trade object