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:
“I think, for the rest of my life, I shall refrain from looking up things. It is the most ravenous time-snatcher I know. You pull one book from the shelf, which carries a hint or a reference that sends you posthaste to another book, and that to successive others. It is incredible, the number of books you hopefully open and disappointedly close, only to take down another with the same result.”
—Carolyn Wells (18621942)
“Indiana was really, I suppose, a Democratic State. It has always been put down in the book as a state that might be carried by a close and careful and perfect organization and a great deal of[from audience: soapMa reference to purchased votes, the word being followed by laughter].
I see reporters here, and therefore I will simply say that everybody showed a great deal of interest in the occasion, and distributed tracts and political documents all through the country.”
—Chester A. Arthur (18291886)