|
The -> Operator
The -> operator is used when a
structure element has to be accessed
through a pointer. The pointer should
be initialized before it can access
any structure element. Consider the
following code fragment, which is used
to initialize pointers for the
user-defined data type invoice created
earlier:
invoice *Invptr;
Invptr = new invoice;
Invptr->iInvoice_no = 1;
Invptr->fInvoice_amt = 100.00;
Another way of initializing pointers
is:
invoice Inv1, *Invptr;
Invptr = &Inv1;
Invptr->iInvoice_no = 1;
Invptr->fInvoice_amt = 100.00; |