views:

1320

answers:

2

Im a bit confused. What is the difference between forward declaration and forward reference? Forward declaration is, in my head, when you declare a function that isnt yet implemented, but is this incorrect? Do you have to look at the specified situation for either declaring a case "forward reference" or "forward declaration"?

+3  A: 

forward declarations are used to allow single-pass compilation of a language (C, Pascal).

if forward references are allowed without forward declaration (Java, C#), a two-pass compiler is required.

Maurice Perry
+1  A: 

From Wiki:

http://en.wikipedia.org/wiki/Forward_declaration

Forward Declaration:

Declaration of a variable or function which are not defined yet. Their defnition can be seen later on.

Forward Reference:

Similar to Forward Declaration but where the variable or function appears first the definition is also in place.

Prabhu. S
Oh. So declaration is when you declare something, use it and then implement it. Reference is when you use, and then declare it?
mslot
Yes. In terms of function references, the definition should have been done before use.
Prabhu. S