Dereference Operator - Composition

Composition

Further information: Pointer: Multiple indirection

The unary * operator, as defined in C and C++, can be used in compositions in cases of multiple indirection, where multiple acts of dereferencing are required. Pointers can of course reference other pointers, and in such cases, multiple applications of the dereference operator are needed. Similarly, the Java dot operator can be used in compositions forming quite sophisticated statements that require substantial dereferencing of pointers behind the scenes during evaluation.

A basic example is in the argv argument to the main function in C (and C++), which is given in the prototype as char **argv – this is because the variable argv itself is a pointer to an array of strings (an array of arrays), so *argv is a pointer to the 0th string (by convention the name of the program), and **argv is the 0th character of the 0th string.

Read more about this topic:  Dereference Operator

Famous quotes containing the word composition:

    I live in the angle of a leaden wall, into whose composition was poured a little alloy of bell-metal. Often, in the repose of my mid-day, there reaches my ears a confused tintinnabulum from without. It is the noise of my contemporaries.
    Henry David Thoreau (1817–1862)

    It is my PRIDE, my damn’d, native, unconquerable Pride, that plunges me into Distraction. You must know that 19-20th of my Composition is Pride. I must either live a Slave, a Servant; to have no Will of my own, no Sentiments of my own which I may freely declare as such;Mor DIE—perplexing alternative!
    Thomas Chatterton (1752–1770)

    Modern Western thought will pass into history and be incorporated in it, will have its influence and its place, just as our body will pass into the composition of grass, of sheep, of cutlets, and of men. We do not like that kind of immortality, but what is to be done about it?
    Alexander Herzen (1812–1870)