Forward Declaration - Forward Reference

The term forward reference is sometimes used as a synonym of forward declaration. However, more often it is taken to refer to the actual use of an entity before any declaration; that is, the first reference to second in the code above is a forward reference. Thus, we may say that because forward declarations are mandatory in Pascal, forward references are prohibited.

An example of (valid) forward reference in C++:

class C { public: void mutator(int x) { myValue = x; } int accessor { return myValue; } private: int myValue; };

In this example, there are two references to myValue before it is declared. C++ generally prohibits forward references, but they are allowed in the special case of class members. Since the member function accessor cannot be compiled until the compiler knows the type of the member variable myValue, it is the compiler's responsibility to remember the definition of accessor until it sees myValue's declaration.

Permitting forward references can greatly increase the complexity and memory requirements of a compiler, and generally prevents the compiler from being implemented in one pass.

Read more about this topic:  Forward Declaration

Famous quotes containing the word reference:

    These roses under my window make no reference to former roses or to better ones; they are for what they are; they exist with God to-day. There is no time to them. There is simply the rose; it is perfect in every moment of its existence.
    Ralph Waldo Emerson (1803–1882)

    A sign, or representamen, is something which stands to somebody for something in some respect or capacity. It addresses somebody, that is, creates in the mind of that person an equivalent sign, or perhaps a more developed sign. That sign which it creates I call the interpretant of the first sign. The sign stands for something, its object. It stands for that object, not in all respects, but in reference to a sort of idea, which I have sometimes called the ground of the representamen.
    Charles Sanders Peirce (1839–1914)