View Single Post
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#10
Languages like C and C++ need to compute the amount of storage that is needed for different types. To do this, the types have to be defined, in some way, to be able to either know, make a guess and fix it later or leave a marker saying that this will be resolved later.

The typical C example is the following:
Code:
struct list {
  int length;
  struct item *first;
};

struct item {
  void *data;
  struct item *next;
};
This will not compile without a forward declaration of
Code:
struct item;
that tells the compiler that there is a symbol named item that is a struct but that it will be defined later so just keep parsing and it will work out.
 

The Following User Says Thank You to Joorin For This Useful Post: