.. highlight:: c++ :linenothreshold: 5 .. _ptr-type: ************ Pointer Type ************ Basics ====== + A derived type to store the memory address of an lvalue + \* symbol after type to make a derived type ``BaseType *ptr;`` + \* operator to dereference a pointer variable ``*ptr`` + & operator to reference an lvalue ``ptr = &lvalue;`` .. _ptr-example: Example ======= :: int value = 10; int *ptr1; ptr1 = &value; // reference the value, now you can use *ptr1 as an alias of value (*ptr1)++; // value increased by 1 and become 11 cout << "The value is " << (*ptr1) << endl; // dereference // type cast to (void *) type to be displayed correctly cout << "The memory address is " << static_cast(ptr1) << endl; + Pitfalls * confusing pointer syntaxes with reference syntaxes Pointer Type Based Data Structures ================================== + Linked-list + Tree + Graph + Hash Table (chained) Related Topics ============== + :ref:`Pointer syntaxes in array` + :doc:`Reference type vs pointer type`