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:

    Since body and soul are radically different from one another and belong to different worlds, the destruction of the body cannot mean the destruction of the soul, any more than a musical composition can be destroyed when the instrument is destroyed.
    —Oscar Cullman. Immortality of the Soul or Resurrection of the Dead? The Witness of the New Testament, ch. 1, Epworth Press (1958)

    Vices enter into the composition of virtues as poisons into the composition of certain medicines. Prudence and common sense mix them together, and make excellent use of them against the misfortunes that attend human life.
    François, Duc De La Rochefoucauld (1613–1680)

    When I think of God, when I think of him as existent, and when I believe him to be existent, my idea of him neither increases nor diminishes. But as it is certain there is a great difference betwixt the simple conception of the existence of an object, and the belief of it, and as this difference lies not in the parts or composition of the idea which we conceive; it follows, that it must lie in the manner in which we conceive it.
    David Hume (1711–1776)