Home Segments Index Top Previous Next

265: Mainline

In Segment 263, you saw trade_price defined as a function of two arguments:

double trade_price (double p, int n) {return p * n;} 

Instead of handing two arguments to trade_price, you can redefine it to take just one argument, which you declare to be a trade object. If you choose this approach, you also need to change the body of trade_price: The body must refer to the trade's price and number structure variables, instead of to price and number parameters, p and n:

double trade_price (struct trade t) {return t.price * t.number;}