< previous page page_978 next page >

Page 978
0978-01.gif
Figure 17-5
Formal Parameter Pointing to an Actual Parameter
Indexing a pointer variable is made possible by the following rule in C++:
Indexing is valid for any pointer expression, not only an array name. (Indexing a pointer only makes sense, though, if the pointer points to an array.)
We have now seen four C++ operators that are valid for pointers: =, *, ->, and []. The following table lists the most common operations that may be applied to pointers.
OperatorMeaningExampleRemarks
=Assignmentptr = &someVar;
ptr1 = ptr2;
ptr = 0;
Except for the null pointer, both operands must be of the same data type.
*Dereference*ptr
==, !=, <, <=, >, and >=Relational operatorsptr1 == ptr2The two operands must be of the same data type.
!Logical NOT!ptrThe result is 1 if the operand is 0 (the null pointer), else the result is 0.
[]Index (or subscript)ptr[4]The indexed pointer should point to an array.
->Member selectionptr->heightSelects a member of the class, struct, or union variable that is pointed to.

 
< previous page page_978 next page >